protected void ibtnSave_Click(object sender, ImageClickEventArgs e) { string userID = ViewState["UserID"].ToString(); DataSet dsUserData = employee.CheckUserNameDuplicate(txtUserName.Text, txtMSADUserName.Text, userID); if (dsUserData != null && dsUserData.Tables[0].Rows.Count == 0) { string ColumnValue = " Location='" + lblLocation.Text.Split('-')[1].ToString().Trim() + "'," + "IMLoc='" + hidLocation.Value.Substring(0, 2) + "'," + "UserInterfaceInd='" + ddlUserInterface.SelectedItem.Value.ToString() + "'," + "MSADUserName='******'", "").Replace("\"", "") + "'," + "DateofLastLogin='******'," + "NoofLogins=" + ((lblNoLogins.Text != "") ? lblNoLogins.Text : "NULL") + "," + "LogonStatusInd='" + lblLogStatus.Text + "'," + "UserName='******'", "").Replace("\"", "") + "'," + "UserPassword='******'", "").Replace("\"", "") + "'," + "Domain='" + txtDomain.Text.Replace("'", "").Replace("\"", "") + "'," + "BuyerInd='" + ddlBuyer.SelectedItem.Value.ToString() + "'," + "ApproveOrderInd='" + ddlApproveOrders.SelectedItem.Value.ToString() + "'," + "ARClerkInd='" + ddlARClerk.SelectedItem.Value.ToString() + "'," + "PrimaryBinPrmpt='" + ddlPrompt.SelectedItem.Value.ToString() + "'," + "PODolLimit=" + ((txtDollarLimit.Text != "") ? txtDollarLimit.Text : "NULL") + "," + "ConsumablesAmt=" + ((txtConsumable.Text != "") ? txtConsumable.Text : "NULL") + "," + "ChangeID='" + Session["UserName"].ToString() + "'," + "ChangeDt='" + DateTime.Now.ToShortDateString() + "'"; employee.UpdateUserData(ColumnValue, userID); status = "Success"; ViewState["Mode"] = "Save"; } else { Label lbl = Page.FindControl("lblMessage") as Label; employee.DisplayMessage(MessageType.Failure, "Username or MSAD Username already exists", lbl); UpdatePanel pnl = Page.FindControl("upnlMessage") as UpdatePanel; pnl.Update(); } upnlUser.Update(); upnlMSAD.Update(); upnlBuyer.Update(); }
protected void BindUserInfo() { lblSearch.Text = ""; EnableTabs(); string whereCondition = ""; int recCount = 0; HiddenField hidLeftFrame = ucUser.FindControl("hidLeftFrameBindMode") as HiddenField; if (ddlSearch.SelectedItem.Value == "Name") { if (hidMode.Value == "Search") // serach initiated by button { whereCondition = " and EM.EmployeeName like '" + txtSearch.Text.Trim() + "%'"; } else { whereCondition = " and EM.EmployeeName ='" + txtSearch.Text.Trim() + "'"; } bool user; DataTable dtUser = employee.CountUser(whereCondition); if (dtUser.Rows.Count > 0 && dtUser != null) { User = user = true; recCount = dtUser.Rows.Count; } else { User = user = false; recCount = 0; } // employee.CheckUser(whereCondition); if (user) { if ((hidLeftFrameBindMode.Value != "Click" && hidLocSearch.Value.Trim() != "Location") || hidMode.Value == "Search") { ucUser.UserInfo = txtSearch.Text.Trim().ToString(); } hidLeftFrameBindMode.Value = ""; hidLeftFrame.Value = ""; hidMode.Value = ""; ucEmpData.EmployeeName = dtUser.Rows[0]["EmployeeName"].ToString(); if (hidLocSearch.Value.Trim() == "Location") { //ucLocation.BindLocation = whereCondition; divLocation.Style.Add(HtmlTextWriterStyle.Display, ""); divUser.Style.Add(HtmlTextWriterStyle.Display, "none"); } else { ucUser.SelectedNode = ucEmpData.EmployeeName; } //ucUser.SelectedNode = ucEmpData.EmployeeName; ucSetting.User = dtUser.Rows[0]["SecUserID"].ToString(); ucSetting.EmployeeName = ucEmpData.EmployeeName; ucSetting.Location = ucEmpData.EmpLocation; ucSecurity.UserName = ucEmpData.EmployeeName; ucSecurity.UserID = ucSetting.UserID; //HighLightTabsheet("employee"); lblMessage.Text = ""; } else { //HighLightTabsheet("none"); lblMessage.Text = "No Records found"; } } else if (ddlSearch.SelectedItem.Value == "UserName") { string whereClause = "SU.UserName like'" + txtSearch.Text.Trim() + "%'"; string empName = ""; bool user; DataTable dtUser = new DataTable(); DataTable dtEmpName = employee.GetUserName(whereClause); //string empName = employee.GetUserName(whereClause); if (dtEmpName != null && dtEmpName.Rows.Count > 0) { foreach (DataRow drName in dtEmpName.Rows) { empName += "'" + drName["EmployeeName"].ToString() + "',"; } empName = (empName != "") ? empName.Remove(empName.Length - 1, 1) : ""; whereCondition = " and EmployeeName in (" + empName + ")"; dtUser = employee.CountUser(whereCondition); } if (dtUser.Rows.Count > 0 && dtUser != null) { user = true; recCount = dtUser.Rows.Count; } else { user = false; recCount = 0; } if (user) { if (hidLeftFrameBindMode.Value != "Click")// && hidLocSearch.Value!="Location") { ucUser.UserInfo = txtSearch.Text.Trim().ToString(); } hidLeftFrameBindMode.Value = ""; hidLeftFrame.Value = ""; if (hidLocSearch.Value.Trim() == "Location") { ucLocation.BindLocation = whereCondition; divLocation.Style.Add(HtmlTextWriterStyle.Display, ""); divUser.Style.Add(HtmlTextWriterStyle.Display, "none"); } else { ucUser.UserInfoOnSearch = empName; ucUser.SelectedNode = ucEmpData.EmployeeName; } //ucUser.UserInfoOnSearch = empName; ucEmpData.EmployeeName = dtUser.Rows[0]["EmployeeName"].ToString(); //ucUser.SelectedNode = ucEmpData.EmployeeName; ucSetting.User = dtUser.Rows[0]["SecUserID"].ToString(); ucSetting.EmployeeName = ucEmpData.EmployeeName; ucSetting.Location = ucEmpData.EmpLocation; ucSecurity.UserName = ucEmpData.EmployeeName; ucSecurity.UserID = ucSetting.UserID; // HighLightTabsheet("employee"); lblMessage.Text = ""; } else { //HighLightTabsheet("none"); employee.DisplayMessage(MessageType.Failure, "No Records Found", lblMessage); } } hidLocSearch.Value = ""; lblSearch.Text = recCount.ToString() + " Records Found"; txtSearch.Text = ""; upnlData.Update(); upnlMessage.Update(); upnlSearchResult.Update(); }
protected void ibtnSave_Click(object sender, ImageClickEventArgs e) { string empName = (txtFirstName.Text.Replace("'", "").Replace("\"", "").Trim() + " " + txtLastName.Text.Replace("'", "").Replace("\"", "").Trim()); string email = ((txtEmail.Text != "") ? (txtEmail.Text.Replace("'", "").Replace("\"", "")) + lblEmail.Text : ""); DateTime stDate = (txtBegin.Text != "") ? Convert.ToDateTime(txtBegin.Text) : DateTime.Now; DateTime endDate = (txtEnd.Text != "") ? Convert.ToDateTime(txtEnd.Text) : DateTime.Now; txtPhone.Text = RemovePhoneNumberFormat(txtPhone.Text.Replace("'", "").Trim()); txtFax.Text = RemovePhoneNumberFormat(txtFax.Text.Replace("'", "").Trim()); if (endDate >= stDate) { if (ViewState["Mode"].ToString() == "Add") { columnValue = "'" + empName + "'," + "'" + ddlHireLocation.SelectedItem.Value.ToString() + "'," + "'" + txtEmpNo.Text.Replace("'", "").Replace("\"", "") + "'," + ((ddlStatus.SelectedItem.Value.ToString() != "") ? ("'" + ddlStatus.SelectedItem.Value.ToString() + "'") : "NULL") + "," + "'" + dtpHireDate.SelectedDate + "'," + ((ddlDepartment.SelectedItem.Value.ToString() != "") ? ddlDepartment.SelectedItem.Value.ToString() : "NULL") + "," + "'" + ((ddlPosition.SelectedItem.Value.ToString() != "") ? ddlPosition.SelectedItem.Value.ToString() : "NULL") + "'," + ((ddlShift.SelectedItem.Value.ToString() != "") ? ("'" + ddlShift.SelectedItem.Value.ToString() + "'") : "NULL") + "," + ((ddlSupervisior.SelectedItem.Value.ToString() != "") ? ("'" + ddlSupervisior.SelectedItem.Value.ToString() + "'") : "NULL") + "," + "'" + txtFirstName.Text.Replace("'", "").Replace("\"", "") + "'," + "'" + txtMiddleName.Text.Replace("'", "").Replace("\"", "").Trim() + "'," + "'" + txtLastName.Text.Replace("'", "").Replace("\"", "") + "'," + ((ddlSalutation.SelectedItem.Value.ToString() != "") ? ("'" + ddlSalutation.SelectedItem.Value.ToString().Trim() + "'") : "NULL") + "," + "'" + email + "'," + "'" + txtPhone.Text + "'," + "'" + txtFax.Text + "'," + "'" + ddlPayCode.SelectedItem.Value.ToString() + "'," + "'" + txtPayrollEmpNo.Text.Replace("'", "").Replace("\"", "") + "'," + "'" + ddlPayrollLoc.SelectedItem.Value.ToString() + "'," + ((txtHoliday.Text != "") ? txtHoliday.Text : "NULL") + "," + ((txtSick.Text != "") ? txtSick.Text : "NULL") + "," + ((txtVacation.Text != "") ? txtVacation.Text : "NULL") + "," + "'" + txtBegin.Text + "'," + "'" + txtEnd.Text + "'," + "'" + txtAbsenceBal.Text + "'," + "" + ((txtBalance.Text != "") ? txtBalance.Text : "NULL") + "," + "'" + Session["UserName"].ToString() + "'," + "'" + DateTime.Now.ToShortDateString() + "'," + ((ddlPosition.SelectedItem.Value.ToString().Trim().ToLower() == "supervisior") ? "'Y'" : "NULL"); // +"'"; string whereClause = "EmployeeName='" + empName + "' and DeleteDt is null"; bool checkUser = employee.CheckUser(whereClause); bool checkUserID = employee.CheckUserID(txtEmpNo.Text.Trim()); Label lbl = Page.FindControl("lblMessage") as Label; if (checkUser) { employee.DisplayMessage(MessageType.Failure, "Employee Name already exists", lbl); UpdatePanel pnl = Page.FindControl("upnlMessage") as UpdatePanel; pnl.Update(); status = "Failure"; } else if (checkUserID) { employee.DisplayMessage(MessageType.Failure, "Employee No. already exists", lbl); UpdatePanel pnl = Page.FindControl("upnlMessage") as UpdatePanel; pnl.Update(); status = "Failure"; } else { string _empID = employee.InsertEmployeeData(columnValue); ViewState["EmpID"] = _empID; status = "NewEmployeeSuccess"; string userSettingcolumnValue = "'" + ddlHireLocation.SelectedItem.Text.ToString().Split('-')[1].ToString().Trim() + "'," + "'" + ddlHireLocation.SelectedItem.Value.ToString() + "'," + "'" + _empID + "'," + "'" + Session["UserName"].ToString() + "'," + "'" + DateTime.Now.ToShortDateString() + "'"; UserID = employee.InsertUserData(userSettingcolumnValue); ViewState["UserID"] = UserID.ToString(); EmployeeName = empName; ViewState["Mode"] = "Save"; } } else { string empID = ViewState["EmpID"].ToString(); string updateValue = "EmployeeName='" + empName.Trim() + "'," + "Location='" + ddlHireLocation.SelectedItem.Value.ToString() + "'," + "EmployeeNo='" + txtEmpNo.Text.Replace("'", "").Replace("\"", "") + "'," + "EmploymentStatus=" + ((ddlStatus.SelectedItem.Value.ToString() != "") ? ("'" + ddlStatus.SelectedItem.Value.ToString() + "'"): "NULL") + "," + "HireDt='" + dtpHireDate.SelectedDate + "'," + "DepartmentNo=" + ((ddlDepartment.SelectedItem.Value.ToString() != "") ? ddlDepartment.SelectedItem.Value.ToString() : "NULL") + "," + "DefaultJobCd=" + ((ddlPosition.SelectedItem.Value.ToString() != "") ? ("'" + ddlPosition.SelectedItem.Value.ToString() + "'") : "NULL") + "," + "Shift='" + ddlShift.SelectedItem.Value.ToString() + "'," + "SupervisorEmpID=" + ((ddlSupervisior.SelectedItem.Value.ToString() != "") ? ddlSupervisior.SelectedItem.Value.ToString() : "NULL") + "," + "SupervisorInd='" + ((ddlPosition.SelectedItem.Value.ToString().Trim().ToLower() == "supervisior") ? "Y" : "") + "'," + "FirstName='" + txtFirstName.Text.Replace("'", "").Replace("\"", "") + "'," + "MiddleInitial='" + txtMiddleName.Text.Replace("'", "").Replace("\"", "") + "'," + "LastName='" + txtLastName.Text.Replace("'", "").Replace("\"", "") + "'," + "Salutation=" + ((ddlSalutation.SelectedItem.Value.ToString() != "")?("'" + ddlSalutation.SelectedItem.Value.ToString() + "'"):"NULL") + "," + "EmailAddress='" + email + "'," + "PhoneNo='" + txtPhone.Text + "'," + "FaxNo='" + txtFax.Text + "'," + "PayCd='" + ddlPayCode.SelectedItem.Value.ToString() + "'," + "PayRollEmployeeNo='" + txtPayrollEmpNo.Text.Replace("'", "").Replace("\"", "") + "'," + "PayRollLocation=" + ((ddlPayrollLoc.SelectedItem.Value.ToString() != "")?("'" + ddlPayrollLoc.SelectedItem.Value.ToString() + "'"):"NULL") + "," + "HolidayHours=" + ((txtHoliday.Text != "") ? txtHoliday.Text : "NULL") + "," + "SickHours=" + ((txtSick.Text != "") ? txtSick.Text : "NULL") + "," + "VacationHours=" + ((txtVacation.Text != "") ? txtVacation.Text : "NULL") + "," + "LeaveBeginDt='" + txtBegin.Text + "'," + "LeaveEndDt='" + txtEnd.Text + "'," + "LeaveBalanceDt='" + txtAbsenceBal.Text + "'," + "BenefitBalance=" + ((txtBalance.Text != "") ? txtBalance.Text : "NULL") + "," + "ChangeID='" + Session["UserName"].ToString() + "'," + "ChangeDt='" + DateTime.Now.ToShortDateString() + "'"; employee.UpdateEmployeeData(updateValue, empID); int userID = Convert.ToInt32((employee.GetUserIDByEmployeeID(empID))); ViewState["UserID"] = userID.ToString(); string userSettingColumnValue = " Location='" + ddlHireLocation.SelectedItem.Text.ToString() + "'," + "IMLoc='" + ddlHireLocation.SelectedItem.Value.ToString() + "'"; employee.UpdateUserData(userSettingColumnValue, userID.ToString()); status = "Success"; EmpLocation = (ddlHireLocation.SelectedItem.Value.ToString()) + "-" + (ddlHireLocation.SelectedItem.Text.ToString()); EmployeeName = empName; ViewState["Mode"] = "Save"; } } else { Label lbl = Page.FindControl("lblMessage") as Label; employee.DisplayMessage(MessageType.Failure, "End Date must be greater than Start Date", lbl); UpdatePanel pnl = Page.FindControl("upnlMessage") as UpdatePanel; pnl.Update(); txtEnd.Text = ""; // ClearControl(); status = "Failure"; } }