protected void UserGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string sqlUser = "";

            if (Session["UserPrivilegeId"].ToString() == "0")
            {
                TextBox txtEUser = (TextBox)UserGridView.Rows[e.RowIndex].FindControl("txtEUser");
                sqlUser = "******" + txtEUser.Text + "',";
            }
            TextBox      txtEName      = (TextBox)UserGridView.Rows[e.RowIndex].FindControl("txtEName");
            DropDownList txtEPrivilege = (DropDownList)UserGridView.Rows[e.RowIndex].FindControl("txtEPrivilege");
            TextBox      txtECpoint    = (TextBox)UserGridView.Rows[e.RowIndex].FindControl("txtECpoint");

            string sql    = "UPDATE tbl_user SET " + sqlUser + " name='" + txtEName.Text + "',level='" + txtEPrivilege.SelectedValue + "',user_cpoint='" + txtECpoint.Text + "' WHERE id = '" + UserGridView.DataKeys[e.RowIndex].Value + "'";
            string script = "";

            if (function.MySqlQuery(sql))
            {
                script = "แก้ไขข้อมูลสำเร็จ";
            }
            else
            {
                script = "Error : แก้ไขข้อมูลล้มเหลว";
            }
            function.Close();
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true);
            UserGridView.EditIndex = -1;
            BindData();
        }
예제 #2
0
        protected void btnConfirmPass_Click(object sender, EventArgs e)
        {
            string script = "";

            if (txtNewPass.Text.Trim() == txtConfirmNewPass.Text.Trim() && txtNewPass.Text.Trim() != "" && txtConfirmNewPass.Text.Trim() != "")
            {
                string sql = "UPDATE tbl_user SET password = '******' WHERE username='******'";
                if (function.MySqlQuery(sql))
                {
                    txtNewPass.Text        = "";
                    txtConfirmNewPass.Text = "";
                    script = "เปลี่ยนรหัสผ่านสำเร็จสำเร็จ<br/>";
                }
                else
                {
                    script = "เปลี่ยนรหัสผ่านสำเร็จล้มเหลว<br/>";
                }
            }
            else
            {
                script = "ใส่ข้อมูลไม่ครบถ้วน หรือ รหัสผ่านใหม่ไม่ตรงกัน";
            }
            function.Close();
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true);
        }
예제 #3
0
        protected void btnUpdateCM_Command(object sender, CommandEventArgs e)
        {
            if (txtEDate.Text != "" && txtETime.Text != "")
            {
                bool chk_time = false;
                try
                {
                    double.Parse(txtETime.Text);
                    chk_time = true;
                }
                catch { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('กรุณาใส่เวลาให้ถูกต้อง ไม่ต้องใส่ น.')", true); }

                if (chk_time)
                {
                    String NewFileDocName = "";
                    if (txtMethod.Text != "")
                    {
                        if (fileImg.HasFile)
                        {
                            string typeFile = fileImg.FileName.Split('.')[fileImg.FileName.Split('.').Length - 1];
                            if (typeFile == "jpg" || typeFile == "jpeg" || typeFile == "png")
                            {
                                NewFileDocName = "E_" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + fileImg.FileName.Split('.')[0];
                                NewFileDocName = "/CM/Upload/" + function.getMd5Hash(NewFileDocName) + "." + typeFile;
                                fileImg.SaveAs(Server.MapPath(NewFileDocName.ToString()));
                                string sql = "UPDATE tbl_cm_detail SET cm_detail_edate = '" + txtEDate.Text + "', cm_detail_etime = '" + txtETime.Text.Trim() + "', cm_detail_note = '" + txtNote.Text.Trim() + "', cm_detail_status_id = '1',cm_detail_eimg='" + NewFileDocName + "',cm_detail_method='" + txtMethod.Text + "' WHERE cm_detail_id = '" + Label1.Text.Replace('#', ' ').Trim() + "'";
                                if (function.MySqlQuery(sql))
                                {
                                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกข้อมูลสำเร็จ')", true);
                                    BindData("");
                                }
                                else
                                {
                                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('ล้มเหลวเกิดข้อผิดพลาด')", true);
                                }
                            }
                            else
                            {
                                //AlertPop("Error : แนบรูปภาพล้มเหลว ไฟล์เอกสารต้องเป็น *.jpg *.jpge *.png เท่านั้น", "error");
                                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : แนบรูปภาพล้มเหลว ไฟล์เอกสารต้องเป็น *.jpg *.jpge *.png เท่านั้น')", true);
                            }
                        }
                        else
                        {
                            //UpdateCM("");
                            //AlertPop("Error : แนบรูปภาพล้มเหลวไม่พบไฟล์", "error");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : แนบรูปภาพล้มเหลวไม่พบไฟล์')", true);
                        }
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('**กรุณาใส่วิธีแก้ไข')", true);
                    }
                }
            }
        }
예제 #4
0
        protected void ClaimGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DropDownList txtStatusEdit = (DropDownList)ClaimGridView.Rows[e.RowIndex].FindControl("txtStatusEdit");

            string sql    = "UPDATE tbl_claim SET claim_status = '" + txtStatusEdit.SelectedValue + "' WHERE claim_id = '" + ClaimGridView.DataKeys[e.RowIndex].Value + "'";
            string script = "";

            if (function.MySqlQuery(sql))
            {
                script = "แก้ไขข้อมูลสำเร็จ";
            }
            else
            {
                script = "Error : แก้ไขข้อมูลล้มเหลว";
            }
            function.Close();
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true);
            ClaimGridView.EditIndex = -1;
            BindData("");
        }
예제 #5
0
        protected void DeviceGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtEDevice = (TextBox)DeviceGridView.Rows[e.RowIndex].FindControl("txtEDevice");

            string sql    = "UPDATE tbl_device SET device_name='" + txtEDevice.Text + "' WHERE device_id = '" + DeviceGridView.DataKeys[e.RowIndex].Value + "'";
            string script = "";

            if (function.MySqlQuery(sql))
            {
                script = "แก้ไขข้อมูลสำเร็จ";
            }
            else
            {
                script = "Error : แก้ไขข้อมูลล้มเหลว";
            }
            function.Close();
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true);
            DeviceGridView.EditIndex = -1;
            BindData("");
        }
        protected void btnSaveCM_Click(object sender, EventArgs e)
        {
            String NewFileDocName = "";

            if (fileImg.HasFile)
            {
                string typeFile = fileImg.FileName.Split('.')[fileImg.FileName.Split('.').Length - 1];
                if (typeFile == "jpg" || typeFile == "jpeg" || typeFile == "png")
                {
                    NewFileDocName = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + fileImg.FileName.Split('.')[0];
                    NewFileDocName = "/CM/Upload/" + function.getMd5Hash(NewFileDocName) + "." + typeFile;
                    fileImg.SaveAs(Server.MapPath(NewFileDocName.ToString()));

                    string sql_insert = "INSERT INTO tbl_cm_detail (cm_detail_driver_id,cm_detail_problem,cm_detail_status_id,cm_detail_channel,cm_detail_sdate,cm_detail_stime,cm_detail_simg,cm_detail_note,cm_cpoint,cm_point,cm_user) VALUES ('" + txtDeviceAdd.SelectedValue + "','" + txtProblem.Text + "','0','" + txtChannel.Text + "','" + txtSDate.Text + "','" + txtSTime.Text + "','" + NewFileDocName + "','" + txtNote.Text + "','" + txtCpoint.SelectedValue + "','" + txtPoint.Text.Trim() + "','" + Session["User"].ToString() + "')";
                    if (function.MySqlQuery(sql_insert))
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกข้อมูลสำเร็จ')", true);
                        BindData("");
                        ClearDate();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('ล้มเหลว เกิดข้อผิดพลาด')", true);
                    }
                }
                else
                {
                    //AlertPop("Error : แนบรูปภาพล้มเหลว ไฟล์เอกสารต้องเป็น *.jpg *.jpge *.png เท่านั้น", "error");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : แนบรูปภาพล้มเหลว ไฟล์เอกสารต้องเป็น *.jpg *.jpge *.png เท่านั้น')", true);
                }
            }
            else
            {
                //AlertPop("Error : แนบรูปภาพล้มเหลวไม่พบไฟล์", "error");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : แนบรูปภาพล้มเหลวไม่พบไฟล์')", true);
            }
        }
        protected void QuotationsGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtENote = (TextBox)QuotationsGridView.Rows[e.RowIndex].FindControl("txtENote");
            string  sql      = "UPDATE tbl_quotations SET quotations_note_number = '" + txtENote.Text + "' WHERE quotations_id = '" + QuotationsGridView.DataKeys[e.RowIndex].Value + "'";

            //string script = "";
            if (function.MySqlQuery(sql))
            {
            }
            QuotationsGridView.EditIndex = -1;
            Response.Redirect("/Techno/TechnoFormDetail");
        }
예제 #8
0
 protected void btnAddCom_Click(object sender, EventArgs e)
 {
     if (txtComName.Text != "")
     {
         string sql = "INSERT INTO tbl_claim_com_working (com_working_name,com_working_pos,detail_com_id) VALUES ('" + txtComName.Text + "','" + txtPosCom.SelectedItem + "','" + Session["CodePK"].ToString() + "')";
         function.MySqlQuery(sql);
         txtComName.Text = "";
         BindCom();
     }
 }