protected void lbxGroup_SelectedIndexChanged(object sender, EventArgs e) { string GroupIds = string.Empty; string EmpIds = string.Empty; for (int i = 0; i < lbxGroup.Items.Count; i++) { if (lbxGroup.Items[i].Selected == true) { GroupIds += lbxGroup.Items[i].Value + ","; } } if (GroupIds != "") { DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); DataTable dtEmpInGroup = objGroupEmp.GetGroup_EmployeeById(Session["CompId"].ToString()); dtEmpInGroup = new DataView(dtEmpInGroup, "Group_Id in(" + GroupIds.Substring(0, GroupIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); for (int i = 0; i < dtEmpInGroup.Rows.Count; i++) { if (!EmpIds.Split(',').Contains(dtEmpInGroup.Rows[i]["Emp_Id"].ToString())) { EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ","; } } if (EmpIds != "") { dtEmp = new DataView(dtEmp, "Emp_Id in(" + EmpIds.Substring(0, EmpIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); } else { dtEmp = new DataTable(); } if (dtEmp.Rows.Count > 0) { Session["dtEmp1"] = dtEmp; gvEmp.DataSource = dtEmp; gvEmp.DataBind(); } else { Session["dtEmp1"] = null; gvEmp.DataSource = null; gvEmp.DataBind(); } } else { gvEmp.DataSource = null; gvEmp.DataBind(); } }
protected void TxtEmpName_TextChanged(object sender, EventArgs e) { string empid = string.Empty; if (txtEmpName.Text != "") { empid = txtEmpName.Text.Split('/')[txtEmpName.Text.Split('/').Length - 1]; DataTable dtEmp = ObjEmp.GetEmployeeMaster(strCompId); dtEmp = new DataView(dtEmp, "Emp_Code='" + empid + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmp.Rows.Count > 0) { empid = dtEmp.Rows[0]["Emp_Id"].ToString(); HidEmpId.Value = empid; } else { DisplayMessage("Employee Not Exists"); txtEmpName.Text = ""; txtEmpName.Focus(); HidEmpId.Value = ""; return; } } }
public void FillGrid() { DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (Session["SessionDepId"] != null) { dtEmp = new DataView(dtEmp, "Department_Id in(" + Session["SessionDepId"].ToString().Substring(0, Session["SessionDepId"].ToString().Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); } if (dtEmp.Rows.Count > 0) { Session["dtEmp"] = dtEmp; gvEmployee.DataSource = dtEmp; gvEmployee.DataBind(); lblTotalRecord.Text = Resources.Attendance.Total_Records + " : " + dtEmp.Rows.Count.ToString() + ""; } }
public void Fillddlprojectname() { DataTable dt = objProjctMaster.GetAllProjectMasteer(); if (dt.Rows.Count > 0) { ddlprojectname.DataSource = dt; ddlprojectname.DataTextField = "Project_Name"; ddlprojectname.DataValueField = "Project_Id"; ddlprojectname.DataBind(); ddlprojectname.Items.Add("--Select--"); ddlprojectname.SelectedValue = "--Select--"; } else { ddlprojectname.Items.Add("--Select--"); ddlprojectname.SelectedValue = "--Select--"; } DataTable dtempname = objEmpmaster.GetEmployeeMaster(Session["CompId"].ToString()); if (dtempname.Rows.Count > 0) { ddlempname.DataSource = dtempname; ddlempname.DataTextField = "Emp_Name"; ddlempname.DataValueField = "Emp_Id"; ddlempname.DataBind(); ddlempname.Items.Add("--Select--"); ddlempname.SelectedValue = "--Select--"; } else { ddlempname.Items.Add("--Select--"); ddlempname.SelectedValue = "--Select--"; } pnlgrid.Visible = true; }
protected void btnSaveSelected_Click(object sender, EventArgs e) { string optype = "1"; DataTable dtUser = new DataTable(); dtUser.Columns.Add("sdwEnrollNumber"); dtUser.Columns.Add("sName"); dtUser.Columns.Add("sPassWord"); dtUser.Columns.Add("iPrivilege"); dtUser.Columns.Add("sTmpData"); dtUser.Columns.Add("sCardNumber"); dtUser.Columns.Add("Emp_Id"); dtUser.Columns.Add("IP"); dtUser.Columns.Add("Port"); dtUser.Columns.Add("Device_Id"); dtUser.Columns.Add("sEnabled"); if (chkFinger.Checked && chkFace.Checked) { optype = "4"; } else if (chkFace.Checked) { optype = "3"; } else if (chkFinger.Checked) { optype = "2"; } for (int rowcount = 0; rowcount < gvUser.Rows.Count; rowcount++) { if (((CheckBox)gvUser.Rows[rowcount].FindControl("chkSel")).Checked) { string EnrollNo = gvUser.DataKeys[rowcount]["sdwEnrollNumber"].ToString(); string Password = gvUser.DataKeys[rowcount]["sPassword"].ToString(); string EmpId = gvUser.DataKeys[rowcount]["Emp_Id"].ToString(); string empname = gvUser.DataKeys[rowcount]["sName"].ToString(); string Privilege = gvUser.DataKeys[rowcount]["iPrivilege"].ToString(); string FingerTemplate = string.Empty; string DeviceId = gvUser.DataKeys[rowcount]["Device_Id"].ToString(); string ip = gvUser.DataKeys[rowcount]["IP"].ToString(); string Port = gvUser.DataKeys[rowcount]["Port"].ToString(); string iflag = string.Empty; string senabled = gvUser.DataKeys[rowcount]["bEnabled"].ToString(); string CardNo = gvUser.DataKeys[rowcount]["sCardNumber"].ToString(); DataRow dr = dtUser.NewRow(); dr["sdwEnrollNumber"] = EnrollNo; dr["sName"] = empname; dr["sPassword"] = Password; dr["iPrivilege"] = Privilege; dr["sEnabled"] = senabled; dr["sCardNumber"] = CardNo; dr["Emp_Id"] = EmpId; dr["Device_Id"] = DeviceId; dr["IP"] = ip; dr["Port"] = Port; dr["sEnabled"] = senabled; dtUser.Rows.Add(dr); } } DataTable dtFinger = new DataTable(); DataTable dtFace = new DataTable(); DataTable dtDistinctDevice = dtUser.DefaultView.ToTable(true, "Device_Id"); for (int devicecounter = 0; devicecounter < dtDistinctDevice.Rows.Count; devicecounter++) { DataTable dtUserByDevice = new DataView(dtUser, "Device_Id='" + dtDistinctDevice.Rows[devicecounter][0].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtUserByDevice.Rows.Count > 0) { string ip = dtUserByDevice.Rows[0]["IP"].ToString(); string Port = dtUserByDevice.Rows[0]["Port"].ToString(); bool IsDeviceConnected = false; if (objDeviceOp.Device_Connection(ip, Convert.ToInt32(Port), 0)) { IsDeviceConnected = true; } for (int rowcount = 0; rowcount < dtUserByDevice.Rows.Count; rowcount++) { objEmp = new EmployeeMaster(); if (rowcount % 50 == 0) { ; } string EnrollNo = dtUserByDevice.Rows[rowcount]["sdwEnrollNumber"].ToString(); string DeviceEmpName = dtUserByDevice.Rows[rowcount]["sName"].ToString(); string Password = dtUserByDevice.Rows[rowcount]["sPassword"].ToString(); string EmpId = dtUserByDevice.Rows[rowcount]["Emp_Id"].ToString(); string Privilege = dtUserByDevice.Rows[rowcount]["iPrivilege"].ToString(); string DeviceId = dtUserByDevice.Rows[rowcount]["Device_Id"].ToString(); string senabled = dtUserByDevice.Rows[rowcount]["sEnabled"].ToString(); string CardNo = dtUserByDevice.Rows[rowcount]["sCardNumber"].ToString(); string FingerTemplate = string.Empty; string iflag = string.Empty; string faceindex = string.Empty; string facedata = string.Empty; string facelength = string.Empty; string fingerindex = string.Empty; if (EmpId.Trim() != "") { DataTable dtEmpD = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmpD = new DataView(dtEmpD, "Emp_Code='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmpD.Rows.Count == 0) { int b = 0; b = objEmp.InsertEmployeeMaster(Session["CompId"].ToString(), DeviceEmpName, DeviceEmpName, EmpId, "", Session["BrandId"].ToString(), Session["LocId"].ToString(), "1", "1", "1", "1", "1", "1", DateTime.Now.ToString(), DateTime.Now.ToString(), "On Role", DateTime.Now.ToString(), "Male", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), "", ""); objEmpParam.InsertEmployeeParameterOnEmployeeInsert(Session["CompId"].ToString(), b.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); } } if (IsDeviceConnected) { if (optype == "2") { DataTable dtFingertemp = objDeviceOp.GetUserFinger(ip, Convert.ToInt32(Port)); if (dtFingertemp.Rows.Count > 0) { dtFingertemp = new DataView(dtFingertemp, "sdwEnrollNumber='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable(); try { FingerTemplate = dtFingertemp.Rows[0]["sTmpData"].ToString(); iflag = dtFingertemp.Rows[0]["iFlag"].ToString(); fingerindex = dtFingertemp.Rows[0]["idwFingerIndex"].ToString(); senabled = dtFingertemp.Rows[0]["sEnabled"].ToString(); } catch { } objEmpInfo.UpdateAccessControlFingerInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString()); } } else if (optype == "3") { DataTable dtFaceTemp = objDeviceOp.GetUserFace(ip, Convert.ToInt32(Port)); if (dtFaceTemp.Rows.Count > 0) { dtFaceTemp = new DataView(dtFaceTemp, "sUSERID='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable(); try { faceindex = dtFaceTemp.Rows[0]["iFaceIndex"].ToString(); facedata = dtFaceTemp.Rows[0]["sTmpData"].ToString(); facelength = dtFaceTemp.Rows[0]["iLength"].ToString(); senabled = dtFaceTemp.Rows[0]["bEnabled"].ToString(); } catch { } objEmpInfo.UpdateAccessControlFaceInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString()); } } else if (optype == "4") { DataTable dtFingertemp = objDeviceOp.GetUserFinger(ip, Convert.ToInt32(Port)); if (dtFingertemp.Rows.Count > 0) { dtFingertemp = new DataView(dtFingertemp, "sdwEnrollNumber='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable(); try { FingerTemplate = dtFingertemp.Rows[0]["sTmpData"].ToString(); iflag = dtFingertemp.Rows[0]["iFlag"].ToString(); fingerindex = dtFingertemp.Rows[0]["idwFingerIndex"].ToString(); senabled = dtFingertemp.Rows[0]["sEnabled"].ToString(); } catch { } objEmpInfo.UpdateAccessControlFingerInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString()); } DataTable dtFaceTemp = objDeviceOp.GetUserFace(ip, Convert.ToInt32(Port)); if (dtFaceTemp.Rows.Count > 0) { dtFaceTemp = new DataView(dtFaceTemp, "sUSERID='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable(); try { faceindex = dtFaceTemp.Rows[0]["iFaceIndex"].ToString(); facedata = dtFaceTemp.Rows[0]["sTmpData"].ToString(); facelength = dtFaceTemp.Rows[0]["iLength"].ToString(); senabled = dtFingertemp.Rows[0]["bEnabled"].ToString(); } catch { } objEmpInfo.UpdateAccessControlFaceInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString()); } } } } } } DisplayMessage("Users Saved"); }
protected void btnDownload_Click(object sender, EventArgs e) { bool bIs = false; bool IsDeviceSelected = false; DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); DataTable dtUser = new DataTable(); foreach (GridViewRow gvdevicerow in gvDevice.Rows) { if (((CheckBox)gvdevicerow.FindControl("chkSelectDevice")).Checked) { IsDeviceSelected = true; IsDeviceSelected = true; int index = gvdevicerow.RowIndex; string port = gvDevice.DataKeys[index]["Port"].ToString(); string IP = gvDevice.DataKeys[index]["IP_Address"].ToString(); string DeviceId = gvDevice.DataKeys[index]["Device_Id"].ToString(); bIs = objDeviceOp.Device_Connection(IP, Convert.ToInt32(port), 0); if (bIs) { DataTable dtUserTemp = new DataTable(); dtUserTemp = objDeviceOp.GetUser(IP, Convert.ToInt32(port)); if (dtUserTemp.Rows.Count > 0) { dtUserTemp.Columns.Add("Device_Id"); dtUserTemp.Columns.Add("IP"); dtUserTemp.Columns.Add("Port"); dtUserTemp.Columns.Add("Emp_Id"); for (int userrowid = 0; userrowid < dtUserTemp.Rows.Count; userrowid++) { DataTable dtEmpTemp = new DataTable(); dtUserTemp.Rows[userrowid]["Device_Id"] = DeviceId; dtUserTemp.Rows[userrowid]["IP"] = IP; dtUserTemp.Rows[userrowid]["Port"] = port; if ((!Convert.IsDBNull(dtUserTemp.Rows[userrowid]["sdwEnrollNumber"])) && dtUserTemp.Rows[userrowid]["sdwEnrollNumber"].ToString() != "") { dtEmpTemp = new DataView(dtEmp, "Emp_Code='" + dtUserTemp.Rows[userrowid]["sdwEnrollNumber"] + "'", "", DataViewRowState.CurrentRows).ToTable(); } if (dtEmpTemp.Rows.Count > 0) { dtUserTemp.Rows[userrowid]["sdwEnrollNumber"] = dtUserTemp.Rows[userrowid]["sdwEnrollNumber"].ToString(); dtUserTemp.Rows[userrowid]["Emp_Id"] = dtUserTemp.Rows[userrowid]["sdwEnrollNumber"]; } else { dtUserTemp.Rows[userrowid]["Emp_Id"] = dtUserTemp.Rows[userrowid]["sdwEnrollNumber"]; dtUserTemp.Rows[userrowid]["sdwEnrollNumber"] = ""; } } //now merge it to User table if (dtUser.Rows.Count == 0) { dtUser = dtUserTemp; } else { dtUser.Merge(dtUserTemp); } } } } } if (rbtnNew.Checked) { try { dtUser = new DataView(dtUser, "sdwEnrollNumber=''", "", DataViewRowState.CurrentRows).ToTable(); } catch { dtUser = null; } } if (dtUser != null && dtUser.Rows.Count > 0) { Session["DtDeviceUser"] = dtUser; gvUser.DataSource = dtUser; gvUser.DataBind(); lblUserCount.Text = dtUser.Rows.Count.ToString(); DisplayMessage(dtUser.Rows.Count.ToString() + " " + "Users Downloaded"); pnlDeviceOp.Visible = true; pnlList.Visible = false; } else { if (!IsDeviceSelected) { DisplayMessage("Please Select Device"); } else { DisplayMessage("User does not exists"); } } }
protected void EmpGroup_CheckedChanged(object sender, EventArgs e) { lblEmp.Text = ""; if (rbtnAllEmp.Checked) { DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmp.Rows.Count > 0) { Session["dtEmp"] = dtEmp; gvEmp.DataSource = dtEmp; gvEmp.DataBind(); lblbinTotalRecord.Text = Resources.Attendance.Total_Records + " : " + dtEmp.Rows.Count.ToString() + ""; DataTable dtEmpInGroup = objGroupEmp.GetGroup_Employee(editid.Value, Session["CompId"].ToString()); if (dtEmpInGroup.Rows.Count > 0) { string EmpIds = string.Empty; for (int i = 0; i < dtEmpInGroup.Rows.Count; i++) { EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ","; } lblEmp.Text += EmpIds; foreach (GridViewRow gvr in gvEmp.Rows) { Label lb = (Label)gvr.FindControl("lblEmpId"); if (EmpIds.Split(',').Contains(lb.Text)) { if (!lblEmp.Text.Split(',').Contains(lb.Text)) { lblEmp.Text += lb.Text + ","; } CheckBox chk = (CheckBox)gvr.FindControl("chkgvSelect"); chk.Checked = true; } } } gvEmp.Columns[0].Visible = true; gvEmp.Columns[1].Visible = false; imgbtnSelectAll1.Visible = true; } } else if (rbtnEmpInGroup.Checked) { DataTable dtEmpInGroup = objGroupEmp.GetGroup_Employee(editid.Value, Session["CompId"].ToString()); string EmpIds = string.Empty; for (int i = 0; i < dtEmpInGroup.Rows.Count; i++) { EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ","; } DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (EmpIds != "") { dtEmpInGroup = new DataView(dtEmp, "Emp_Id in(" + EmpIds.Substring(0, EmpIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); } Session["dtEmp"] = dtEmpInGroup; gvEmp.DataSource = dtEmpInGroup; gvEmp.DataBind(); lblbinTotalRecord.Text = Resources.Attendance.Total_Records + " : " + dtEmpInGroup.Rows.Count.ToString() + ""; gvEmp.Columns[1].Visible = true; gvEmp.Columns[0].Visible = false; imgbtnSelectAll1.Visible = false; } else if (rbtnEmpNotInGroup.Checked) { DataTable dtEmpInGroup = objGroupEmp.GetGroup_Employee(editid.Value, Session["CompId"].ToString()); string EmpIds = string.Empty; for (int i = 0; i < dtEmpInGroup.Rows.Count; i++) { EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ","; } DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (EmpIds != "") { dtEmpInGroup = new DataView(dtEmp, "Emp_Id not in(" + EmpIds.Substring(0, EmpIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); } else { dtEmpInGroup = dtEmp; } Session["dtEmp"] = dtEmpInGroup; gvEmp.DataSource = dtEmpInGroup; gvEmp.DataBind(); lblbinTotalRecord.Text = Resources.Attendance.Total_Records + " : " + dtEmpInGroup.Rows.Count.ToString() + ""; gvEmp.Columns[0].Visible = true; gvEmp.Columns[1].Visible = false; imgbtnSelectAll1.Visible = true; } }
protected void btnSave_Click(object sender, EventArgs e) { int b = 0; if (txtBrandCode.Text == "") { DisplayMessage("Enter Brand Code"); txtBrandCode.Focus(); return; } if (txtBrandName.Text == "") { DisplayMessage("Enter Brand Name"); txtBrandName.Focus(); return; } if (Session["empimgpath"] == null) { Session["empimgpath"] = ""; } string empid = string.Empty; if (txtManagerName.Text != "") { empid = txtManagerName.Text.Split('/')[txtManagerName.Text.Split('/').Length - 1]; DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Emp_Code='" + empid + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmp.Rows.Count > 0) { empid = dtEmp.Rows[0]["Emp_Id"].ToString(); } else { DisplayMessage("Employee Not Exists"); txtManagerName.Text = ""; txtManagerName.Focus(); return; } } else { empid = "0"; } if (editid.Value == "") { DataTable dt = objBrand.GetBrandMaster(Session["CompId"].ToString()); dt = new DataView(dt, "Brand_Code='" + txtBrandCode.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt.Rows.Count > 0) { DisplayMessage("Brand Code Already Exists"); txtBrandCode.Focus(); return; } DataTable dt1 = objBrand.GetBrandMaster(Session["CompId"].ToString()); dt1 = new DataView(dt1, "Brand_Name='" + txtBrandName.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt1.Rows.Count > 0) { DisplayMessage("Brand Name Already Exists"); txtBrandName.Focus(); return; } b = objBrand.InsertBrandMaster(Session["CompId"].ToString(), txtBrandName.Text, txtBrandNameL.Text, txtBrandCode.Text, empid, Session["empimgpath"].ToString(), "", "", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { string strMaxId = string.Empty; strMaxId = b.ToString(); foreach (GridViewRow gvr in GvAddressName.Rows) { Label lblGvAddressName = (Label)gvr.FindControl("lblgvAddressName"); if (lblGvAddressName.Text != "") { DataTable dtAddId = AM.GetAddressDataByAddressName(Session["CompId"].ToString(), lblGvAddressName.Text); if (dtAddId.Rows.Count > 0) { string strAddressId = dtAddId.Rows[0]["Trans_Id"].ToString(); objAddChild.InsertAddressChild(strAddressId, "Brand", strMaxId, "True", "", "", "", "", "", "True", DateTime.Now.ToString(), "True", Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); } } } DisplayMessage("Record Saved"); FillGrid(); Reset(); btnList_Click(null, null); } else { DisplayMessage("Record Not Saved"); } } else { DataTable dt = objBrand.GetBrandMaster(Session["CompId"].ToString()); string BrandCode = string.Empty; string BrandName = string.Empty; try { BrandCode = (new DataView(dt, "Brand_Id='" + editid.Value + "'", "", DataViewRowState.CurrentRows).ToTable()).Rows[0]["Brand_Code"].ToString(); } catch { BrandCode = ""; } dt = new DataView(dt, "Brand_Code='" + txtBrandCode.Text + "' and Brand_Code<>'" + BrandCode + "' ", "", DataViewRowState.CurrentRows).ToTable(); if (dt.Rows.Count > 0) { DisplayMessage("Brand Code Already Exists"); txtBrandCode.Focus(); return; } DataTable dt1 = objBrand.GetBrandMaster(Session["CompId"].ToString()); try { BrandName = (new DataView(dt1, "Brand_Id='" + editid.Value + "'", "", DataViewRowState.CurrentRows).ToTable()).Rows[0]["Brand_Name"].ToString(); } catch { BrandName = ""; } dt1 = new DataView(dt1, "Brand_Name='" + txtBrandName.Text + "' and Brand_Name<>'" + BrandName + "' ", "", DataViewRowState.CurrentRows).ToTable(); if (dt1.Rows.Count > 0) { DisplayMessage("Brand Name Already Exists"); txtBrandName.Focus(); return; } b = objBrand.UpdateBrandMaster(Session["CompId"].ToString(), editid.Value, txtBrandName.Text, txtBrandNameL.Text, txtBrandCode.Text, empid, Session["empimgpath"].ToString(), "", "", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { objAddChild.DeleteAddressChild("Brand", editid.Value); foreach (GridViewRow gvr in GvAddressName.Rows) { Label lblGvAddressName = (Label)gvr.FindControl("lblgvAddressName"); if (lblGvAddressName.Text != "") { DataTable dtAddId = AM.GetAddressDataByAddressName(Session["CompId"].ToString(), lblGvAddressName.Text); if (dtAddId.Rows.Count > 0) { string strAddressId = dtAddId.Rows[0]["Trans_Id"].ToString(); objAddChild.InsertAddressChild(strAddressId, "Brand", editid.Value, "True", "", "", "", "", "", "True", DateTime.Now.ToString(), "True", Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); } } } btnList_Click(null, null); DisplayMessage("Record Updated"); Reset(); FillGrid(); } else { DisplayMessage("Record Not Updated"); } } }
protected void btnSave_Click(object sender, EventArgs e) { int b = 0; if (txtDeviceName.Text == "") { DisplayMessage("Enter Device Name"); txtDeviceName.Focus(); return; } if (txtIPAddress.Text == "") { DisplayMessage("Enter IP Address"); txtIPAddress.Focus(); return; } if (editid.Value == "") { DataTable dt1 = objDevice.GetDeviceMaster(Session["CompId"].ToString()); DataTable dt2 = new DataView(dt1, "Device_Name='" + txtDeviceName.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt2.Rows.Count > 0) { DisplayMessage("Device Name Already Exists"); txtDeviceName.Focus(); return; } DataTable dt3 = new DataView(dt1, "IP_Address='" + txtIPAddress.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt3.Rows.Count > 0) { DisplayMessage("IP Address Already Exists"); txtIPAddress.Focus(); return; } b = objDevice.InsertDeviceMaster(Session["CompId"].ToString(), txtDeviceName.Text, txtDeviceNameL.Text, Session["BrandId"].ToString(), Session["LocId"].ToString(), txtIPAddress.Text, ddlCommType.Text, txtPortNumber.Text, "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { EmployeeMaster objEmp = new EmployeeMaster(); DataTable dtEmp = new DataTable(); string EmpSync = string.Empty; EmpSync = objAppParam.GetApplicationParameterValueByParamName("Employee Synchronization", Session["CompId"].ToString()); if (EmpSync == "Company") { dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); if (dtEmp.Rows.Count > 0) { for (int i = 0; i < dtEmp.Rows.Count; i++) { objSer.InsertUserTransfer(dtEmp.Rows[i]["Emp_Id"].ToString(), b.ToString(), false.ToString(), DateTime.Now.ToString(), "1/1/1900", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); } } } else { dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmp.Rows.Count > 0) { for (int i = 0; i < dtEmp.Rows.Count; i++) { objSer.InsertUserTransfer(dtEmp.Rows[i]["Emp_Id"].ToString(), b.ToString(), false.ToString(), DateTime.Now.ToString(), "1/1/1900", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); } } } DisplayMessage("Record Saved"); FillGrid(); Reset(); btnList_Click(null, null); } else { DisplayMessage("Record Not Saved"); } } else { string DeviceTypeName = string.Empty; DataTable dt1 = objDevice.GetDeviceMaster(Session["CompId"].ToString()); try { DeviceTypeName = new DataView(dt1, "Device_Id='" + editid.Value + "'", "", DataViewRowState.CurrentRows).ToTable().Rows[0]["Device_Name"].ToString(); } catch { DeviceTypeName = ""; } dt1 = new DataView(dt1, "Device_Name='" + txtDeviceName.Text + "' and Device_Name<>'" + DeviceTypeName + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt1.Rows.Count > 0) { DisplayMessage("Device Name Already Exists"); txtDeviceName.Focus(); return; } DataTable dt3 = objDevice.GetDeviceMaster(Session["CompId"].ToString()); dt3 = new DataView(dt3, "IP_Address='" + txtIPAddress.Text + "' and Device_Id<>'" + editid.Value + "' ", "", DataViewRowState.CurrentRows).ToTable(); if (dt3.Rows.Count > 0) { DisplayMessage("IP Address Already Exists"); txtIPAddress.Focus(); return; } b = objDevice.UpdateDeviceMaster(editid.Value, Session["CompId"].ToString(), txtDeviceName.Text, txtDeviceNameL.Text, Session["BrandId"].ToString(), Session["LocId"].ToString(), txtIPAddress.Text, ddlCommType.Text, txtPortNumber.Text, "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { btnList_Click(null, null); DisplayMessage("Record Updated"); Reset(); FillGrid(); } else { DisplayMessage("Record Not Updated"); } } }
protected void btnSave_Click(object sender, EventArgs e) { int b = 0; if (txtDeptName.Text == "") { DisplayMessage("Enter Department Name"); txtDeptName.Focus(); return; } if (txtDeptCode.Text == "") { DisplayMessage("Enter Department Code"); txtDeptCode.Focus(); return; } string empid = string.Empty; if (txtManagerName.Text != "") { empid = txtManagerName.Text.Split('/')[txtManagerName.Text.Split('/').Length - 1]; DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "' ", "", DataViewRowState.CurrentRows).ToTable(); dtEmp = new DataView(dtEmp, "Emp_Code='" + empid + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dtEmp.Rows.Count > 0) { empid = dtEmp.Rows[0]["Emp_Id"].ToString(); } else { DisplayMessage("Employee Not Exists"); txtManagerName.Text = ""; txtManagerName.Focus(); return; } } else { empid = "0"; } if (editid.Value == "") { DataTable dt = objDep.GetDepartmentMaster(Session["CompId"].ToString()); dt = new DataView(dt, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "' ", "", DataViewRowState.CurrentRows).ToTable(); dt = new DataView(dt, "Dep_Code='" + txtDeptCode.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt.Rows.Count > 0) { DisplayMessage("Department Code Already Exists"); txtDeptCode.Focus(); return; } DataTable dt1 = objDep.GetDepartmentMaster(Session["CompId"].ToString()); dt1 = new DataView(dt1, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "' ", "", DataViewRowState.CurrentRows).ToTable(); dt1 = new DataView(dt1, "Dep_Name='" + txtDeptName.Text + "'", "", DataViewRowState.CurrentRows).ToTable(); if (dt1.Rows.Count > 0) { DisplayMessage("Department Name Already Exists"); txtDeptName.Focus(); return; } b = objDep.InsertDepartmentMaster(Session["CompId"].ToString(), txtDeptName.Text, txtDeptNameL.Text, txtDeptCode.Text, Session["BrandId"].ToString(), Session["LocId"].ToString(), ddlParentDep.SelectedValue, txtPhoneNo.Text, txtFax.Text, empid, "", "0", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { DisplayMessage("Record Saved"); FillGrid(); Reset(); } else { DisplayMessage("Record Not Saved"); } } else { DataTable dt = objDep.GetDepartmentMaster(Session["CompId"].ToString()); string DepartmentCode = string.Empty; string DepartmentName = string.Empty; try { DepartmentCode = (new DataView(dt, "Dep_Id='" + editid.Value + "'", "", DataViewRowState.CurrentRows).ToTable()).Rows[0]["Dep_Code"].ToString(); } catch { DepartmentCode = ""; } dt = new DataView(dt, "Dep_Code='" + txtDeptCode.Text + "' and Dep_Code<>'" + DepartmentCode + "' ", "", DataViewRowState.CurrentRows).ToTable(); if (dt.Rows.Count > 0) { DisplayMessage("Department Code Already Exists"); txtDeptCode.Focus(); return; } DataTable dt1 = objDep.GetDepartmentMaster(Session["CompId"].ToString()); try { DepartmentName = (new DataView(dt1, "Dep_Id='" + editid.Value + "'", "", DataViewRowState.CurrentRows).ToTable()).Rows[0]["Dep_Name"].ToString(); } catch { DepartmentName = ""; } dt1 = new DataView(dt1, "Dep_Name='" + txtDeptName.Text + "' and Dep_Name<>'" + DepartmentName + "' ", "", DataViewRowState.CurrentRows).ToTable(); if (dt1.Rows.Count > 0) { DisplayMessage("Department Name Already Exists"); txtDeptName.Focus(); return; } b = objDep.UpdateDepartmentMaster(editid.Value, Session["CompId"].ToString(), Session["LocId"].ToString(), txtDeptName.Text, txtDeptNameL.Text, txtDeptCode.Text, Session["BrandId"].ToString(), ddlParentDep.SelectedValue, txtPhoneNo.Text, txtFax.Text, empid, "", "0", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString()); if (b != 0) { btnList_Click(null, null); DisplayMessage("Record Updated"); Reset(); FillGrid(); } else { DisplayMessage("Record Not Updated"); } } }