foreach(DataGridView row in dgv2.Rows)
{
for(int i = 0; i < dgv2.Columns.Count; i++)
{
cmd1 = new SqlCommand("select * from Cometowork1 where Empid=@Empid and Date=@Date", con);
cmd1.Parameters.AddWithValue("@Empid", Convert.ToString(dgv2.Rows[i].Cells[0].Value ?? DBNull.Value));
cmd1.Parameters.AddWithValue("@Date", dtp1.Text);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(ds1);
int i = ds1.Tables[0].Rows.Count;
if (i > 0)
{
DialogResult result = MessageBox.Show("ข้อมูลซ้ำโปรดตรวจสอบ", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
ds1.Clear();
}
else
foreach(DataGridView row in dgv2.Rows)
var id = row.Cells[ตำแหน่งที่ต้องการ].value;
ประวัติการแก้ไข 2019-07-05 07:18:28
Date :
2019-07-05 07:17:51
By :
Chaidhanan
No. 3
Guest
Code (C#)
foreach(DataGridView row in dgv2.Rows)
{
for(int i = 0; i < dgv2.Columns.Count; i++)
{
cmd1 = new SqlCommand("select * from Cometowork1 where Empid=@Empid and Date=@Date", con);
cmd1.Parameters.AddWithValue("@Empid", Convert.ToString(dgv2.Rows[i].Cells[0].Value ?? DBNull.Value));
cmd1.Parameters.AddWithValue("@Date", dtp1.Text);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(ds1);
int i = ds1.Tables[0].Rows.Count;
if (i > 0)
{
DialogResult result = MessageBox.Show("ข้อมูลซ้ำโปรดตรวจสอบ", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
ds1.Clear();
}
else
คิดว่า Mobile First (Web App/Windows App --- ไม่อยู่ในสายตา)
Code (SQL)
USE [YourDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF OBJECT_ID ( '[dbo].[msrFormPerm_usp01]', 'P' ) IS NOT NULL
DROP PROCEDURE [dbo].[msrFormPerm_usp01]
GO
CREATE PROCEDURE [dbo].[msrFormPerm_usp01]
(
@PageID AS int = 0,
@RoleIDc AS nvarchar(MAX) = '',
@UserID AS int = 0
)
AS
BEGIN
SET NOCOUNT ON ;
DECLARE @strSQL AS nvarchar(MAX) ='' ;
SET @strSQL = 'SELECT c.ACL,
0 As Flag,
0 As Priority
FROM msrFormPerm c WHERE c.PageID ='
+ CAST(@PageID AS varchar)
+ ' '
+ 'AND (c.RoleID = 0 OR c.RoleID IS NULL) AND c.UserID ='
+ ' '
+ CAST(@UserID AS varchar)
+ ' '
+ 'AND c.IsActive = 1'
+ ' '
+ 'UNION ALL'
+ ' '
+ 'SELECT a.ACL,
1 As Flag,
b.Priority
FROM msrFormPerm a INNER JOIN msrRoles b ON a.RoleID = b.RoleID
WHERE a.PageID ='
+ ' '
+ CAST(@PageID AS varchar)
+ ' '
+ 'AND a.RoleID IN('
+ @RoleIDc
+ ') '
+ 'AND (a.UserID = 0 OR a.UserID IS NULL) AND a.IsActive = 1 AND b.IsActive = 1' ;
EXEC sp_executesql @strSQL ;
END
GO