private Boolean CreateGroupPermission() { string sql; class_is.dbconfig db = new class_is.dbconfig(); DataSet ds = new DataSet(); int idGroup; sql = "INSERT [USER_GROUP] (GroupName) VALUES ('" + txtAddGroup.Text + "') "; //sql += "select SCOPE_IDENTITY() "; db.ExecuteSQL(sql); sql = "SELECT IDENT_CURRENT('[USER_GROUP]') "; ds = db.getData(sql); idGroup = int.Parse(ds.Tables[0].Rows[0][0].ToString()); for (int i = 1; i <= Int32.Parse(hdCountLine.Value); i++) { CheckBox chk = (CheckBox)tbList.FindControl("Chk_" + i); if (chk != null) { if (chk.Checked == true) { sql = "insert [GROUP_MENU_PERMISSION] ([GROUP_ID],[MENU_ID_PERMISSION]) VALUES "; sql += "(" + idGroup + "," + i + ")"; if (db.ExecuteSQL(sql) == false) { return(false); } } } ; } return(true); }
private Boolean SaveData() { SqlConnection conn; SqlCommand command; string sql; DataSet ds; class_is.dbconfig db = new class_is.dbconfig(); //config = db.config(); conn = new SqlConnection(db.config()); sql = "INSERT INTO [IS].[dbo].[USER] "; sql += "(USER_NAME,PASSWORD,USER_GROUP,LINE_ID,FIRST_NAME,LAST_NAME,USER_CODE,DEPARTMENT,EMAIL) "; sql += "VALUES ( "; sql += "'" + txtUserName.Text + "'"; sql += "'Password'"; sql += "'" + ddlGroup.SelectedValue + "'"; sql += "'" + txtLine.Text + "'"; sql += "'" + txtFName.Text + "'"; sql += "'" + txtLName.Text + "'"; sql += "'" + txtEmpID.Text + "'"; sql += "'" + ddlDep.SelectedValue + "'"; sql += "'" + txtEmail.Text + "'"; sql += ")"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("ยืนยันยกเลิกการลางาน", "", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Boolean DeleteSuccess = false; string LeaveID = Request.QueryString["Req"]; string sql; class_is.dbconfig db = new class_is.dbconfig(); sql = "UPDATE [REQUEST_LEAVE] SET "; sql += "STATUS = 'C',"; sql += "CANCEL_DATE = sysdatetime()"; sql += "WHERE LEAVE_ID = '" + LeaveID + "'"; //sql = "DELETE FROM [REQUEST_LEAVE] "; //sql += "WHERE LEAVE_ID = '" + reqID + "' "; DeleteSuccess = db.ExecuteSQL(sql); if (DeleteSuccess) { Response.Write("<script> alert('Delete Complete') </script>"); Response.Write("<script> window.close(); </script>"); } else { Response.Write("<script> alert('Delete Error') </script>"); Response.Write("<script> window.close(); </script>"); } } else if (dialogResult == DialogResult.No) { Response.Write("<script> window.close(); </script>"); } }
protected void btnSave_Click(object sender, EventArgs e) { class_is.dbconfig db = new class_is.dbconfig(); string sql = ""; string LeaveID; string Comment; //foreach (DataGridItem item in dtgList.Items) for (int i = 0; i <= dtgList.Items.Count - 1; i++) { RadioButton rbValid = (RadioButton)dtgList.Items[i].Cells[0].FindControl("rd1"); RadioButton rbNValid = (RadioButton)dtgList.Items[i].Cells[1].FindControl("rd2"); TextBox txtComment = (TextBox)dtgList.Items[i].Cells[12].FindControl("txtComment"); if (rbValid != null && rbValid.Checked) { //update Status Request = A LeaveID = dtgList.Items[i].Cells[2].Text.ToString(); Comment = txtComment.Text.ToString(); sql += UpdateStatusRequest(LeaveID, "A", Comment); } else if (rbNValid != null && rbNValid.Checked) { // Update Status Request = R LeaveID = dtgList.Items[i].Cells[2].Text.ToString(); Comment = txtComment.Text.ToString(); sql += UpdateStatusRequest(LeaveID, "R", Comment); } } if (db.ExecuteSQL(sql)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Save Successfully!!!'); window.location='SearchRequestLeave.aspx';", true); //BindData(); } }
private Boolean SaveData() { string sql; int Group = Int16.Parse(ddlGroup.SelectedValue); class_is.dbconfig db = new class_is.dbconfig(); if (deleteAllPermission(Group)) { for (int i = 1; i <= Int32.Parse(hdCountLine.Value); i++) { //HtmlInputCheckBox chk = (HtmlInputCheckBox)this.Master.FindControl("ContentPlaceHolder1").FindControl("Chk_" + i); CheckBox chkTest = (CheckBox)tbList.FindControl("Chk_" + i); if (chkTest != null) { if (chkTest.Checked == true) { sql = "insert [GROUP_MENU_PERMISSION] ([GROUP_ID],[MENU_ID_PERMISSION]) VALUES "; sql += "(" + Group + "," + i + ")"; if (db.ExecuteSQL(sql) == false) { return(false); } } } ; } } return(true); }
private Boolean UpdateData() { string sql; class_is.dbconfig db = new class_is.dbconfig(); if (FileUpload.FileName != "") { FileUpload.SaveAs(Server.MapPath("Files") + "//" + FileUpload.FileName); } sql = "UPDATE [REQUEST_LEAVE] SET "; sql += "LEAVETYPE_ID = '" + ddlLeaveType.SelectedValue + "',"; sql += "FROM_LEAVE_DATE = '" + setFormatDate(txtFDateLeave.Text) + "',"; sql += "FROM_LEAVE_TIME = '" + txtFTimeLeave.Text + "',"; sql += "TO_LEAVE_DATE = '" + setFormatDate(txtTDateLeave.Text) + "',"; sql += "TO_LEAVE_TIME = '" + txtTTimeLeave.Text + "',"; sql += "NO_LEAVE = '" + txtDay.Text + "',"; sql += "NO_LEAVE_HOUR = '" + txtHour.Text + "',"; sql += "NOTE = '" + txtCauseleave.Text + "',"; sql += "CONTACT = '" + txtContact.Text + "',"; sql += "CONTACT_TEL = '" + txtTelContact.Text + "',"; sql += "STATUS = 'I',"; sql += "UPDATE_DATE = sysdatetime(),"; sql += "UPDATE_BY = '" + Session["empCode"] + "'"; sql += "WHERE LEAVE_ID = '" + Request.QueryString["Req"] + "'"; return(db.ExecuteSQL(sql)); }
private Boolean SaveData() { class_is.dbconfig db = new class_is.dbconfig(); string sql = ""; string reqID; for (int i = 0; i <= dtgList.Items.Count - 1; i++) { RadioButton rbValid = (RadioButton)dtgList.Items[i].Cells[0].FindControl("rd1"); //RadioButton rbNValid = (RadioButton)dtgList.Items[i].Cells[1].FindControl("rd2"); if (rbValid != null && rbValid.Checked) { //update Status Request = A reqID = dtgList.Items[i].Cells[1].Text.ToString(); sql += UpdateStatusConfirm(reqID, "A"); } //else if (rbNValid != null && rbNValid.Checked) //{ // // Update Status Request = R // reqID = dtgList.Items[i].Cells[2].Text.ToString(); // sql += UpdateStatusConfirm(reqID, "R"); //} } if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } }
private Boolean deleteAllPermission(int _Group) { string sql; class_is.dbconfig db = new class_is.dbconfig(); sql = "delete from [GROUP_MENU_PERMISSION] "; sql += "where [GROUP_ID] = " + _Group + ""; return(db.ExecuteSQL(sql)); }
private Boolean deleteData() { string sql; DataSet ds = new DataSet(); class_is.dbconfig db = new class_is.dbconfig(); sql = "delete from [USER] where USER_NAME = '" + txtUserName.Text + "'"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } }
private Boolean UpdateData() { string sql; class_is.dbconfig db = new class_is.dbconfig(); sql = "update [ROLE_NO_LEAVE] set "; sql += "NO_LEAVE = '" + txtNoLeave.Text + "'"; sql += "where ROLE_ID = '" + ddlRole.SelectedValue + "'"; sql += "and LEAVE_TYPE = '" + ddlLeaveType.SelectedValue + "'"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } }
private Boolean SaveData() { string sql; class_is.dbconfig db = new class_is.dbconfig(); if (FileUpload.FileName != "") { FileUpload.SaveAs(Server.MapPath("Files") + "//" + FileUpload.FileName); } sql = "INSERT INTO [REQUEST_LEAVE] ( "; sql += "[LEAVETYPE_ID],[FROM_LEAVE_DATE],[FROM_LEAVE_TIME] "; sql += ",[TO_LEAVE_DATE],[TO_LEAVE_TIME],[NO_LEAVE],[NO_LEAVE_HOUR] "; sql += ",[NOTE],[CONTACT],[CONTACT_TEL],[STATUS],[APPROVE_BY],[REQ_CONFIRM],CONFIRM_BY "; sql += ",[CREATE_DATE],[CREATE_BY],[UPDATE_DATE],[UPDATE_BY] "; sql += ") VALUES ("; sql += "'" + ddlLeaveType.SelectedValue + "',"; sql += "'" + setFormatDate(txtFDateLeave.Text) + "',"; sql += "'" + txtFTimeLeave.Text + "',"; sql += "'" + setFormatDate(txtTDateLeave.Text) + "',"; sql += "'" + txtTTimeLeave.Text + "',"; sql += "'" + txtDay.Text + "',"; sql += "'" + txtHour.Text + "',"; sql += "'" + txtCauseleave.Text + "',"; sql += "'" + txtContact.Text + "',"; sql += "'" + txtTelContact.Text + "',"; sql += "'I',"; sql += "'" + getuserApprComfirm("3") + "',"; if (ddlLeaveType.SelectedValue == "3") // ถ้าประเภทการลาเป็นลาพักร้อนจะ set req_confirm เป็น FALSE เพื่อมีการยืนยันการ confirm ต่อไป { sql += "'FALSE',"; } else { sql += "'TRUE',"; } sql += "'" + getuserApprComfirm("4") + "',"; sql += "sysdatetime(),"; sql += "'" + Session["empCode"] + "',"; sql += "sysdatetime(),"; sql += "'" + Session["empCode"] + "'"; sql += ")"; return(db.ExecuteSQL(sql)); }
private Boolean InsertData() { string sql; class_is.dbconfig db = new class_is.dbconfig(); sql = "insert into [ROLE_NO_LEAVE] (ROLE_ID,LEAVE_TYPE,NO_LEAVE) "; sql += "VALUES ( "; sql += "'" + ddlRole.SelectedValue + "',"; sql += "'" + ddlLeaveType.SelectedValue + "',"; sql += "'" + txtNoLeave.Text + "'"; sql += ")"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } }
private Boolean SaveData() { string sql; class_is.dbconfig db = new class_is.dbconfig(); class_is.ClassLeaveSystem objLeave = new class_is.ClassLeaveSystem(); if (Mode == "Edit") { sql = "UPDATE [USER] SET "; sql += "USER_GROUP = '" + ddlGroup.SelectedValue + "',"; sql += "ROLE_ID = '" + ddlRole.SelectedValue + "',"; sql += "LINE_ID = '" + txtLine.Text + "',"; sql += "FIRST_NAME = '" + txtFName.Text + "',"; sql += "LAST_NAME = '" + txtLName.Text + "',"; sql += "EMP_CODE = '" + txtEmpID.Text + "',"; sql += "DeptID = '" + ddlDep.SelectedValue + "',"; sql += "EMAIL = '" + txtEmail.Text + "'"; sql += "where USER_NAME = '" + userName + "'"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } } else { if (UserNameExist()) { Response.Write("<script> alert('User Name is Exist') </script>"); return(false); } else if (empCodeExist()) { Response.Write("<script> alert('Emp Code is Exist') </script>"); return(false); } else { sql = "INSERT INTO [USER] "; sql += "(USER_NAME,PASSWORD,USER_GROUP,ROLE_ID,LINE_ID,FIRST_NAME,LAST_NAME,EMP_CODE,DeptID,EMAIL) "; sql += "VALUES ( "; sql += "'" + txtUserName.Text + "',"; sql += "'" + objLeave.ComputeHash(txtPassword.Text, "SHA512", null) + "',"; sql += "'" + ddlGroup.SelectedValue + "',"; sql += "'" + ddlRole.SelectedValue + "',"; sql += "'" + txtLine.Text + "',"; sql += "'" + txtFName.Text + "',"; sql += "'" + txtLName.Text + "',"; sql += "'" + txtEmpID.Text + "',"; sql += "'" + ddlDep.SelectedValue + "',"; sql += "'" + txtEmail.Text + "'"; sql += ")"; if (db.ExecuteSQL(sql)) { return(true); } else { return(false); } } } }