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();
        }
Exemple #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);
        }
Exemple #3
0
        protected void ComGridView_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            string sql = "DELETE FROM tbl_claim_com_working WHERE com_working_id = '" + ComGridView.DataKeys[e.RowIndex].Value + "'";

            //string script = "";
            function.MySqlQuery(sql);
            function.Close();
            //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true);
            ComGridView.EditIndex = -1;
            BindCom();
        }
        protected void btnSubmit_Click1(object sender, EventArgs e)
        {
            string mess = "";

            if (txtUser.Text.Trim() == "")
            {
                mess += "- กรุณาป้อน Username<br/>";
            }

            if (txtPass.Text.Trim() == "")
            {
                mess += "- กรุณาป้อน Password<br/>";
            }

            if (mess == "")
            {
                string          sql = "SELECT * FROM tbl_user WHERE username ='******' AND PASSWORD = '******'";
                MySqlDataReader rs  = function.MySqlSelect(sql);
                if (rs.Read())
                {
                    if (!rs.IsDBNull(0))
                    {
                        // Storee Session
                        Session.Add("User", txtUser.Text);
                        Session.Add("UserName", rs.GetString("name"));
                        Session.Add("UserPrivilegeId", rs.GetString("level"));
                        Session.Add("UserPrivilege", function.GetLevel(int.Parse(rs.GetString("level"))));
                        Session.Add("UserCpoint", rs.GetString("user_cpoint"));
                        Session.Timeout = 60 * 24;

                        //Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message Box", "<script language = 'javascript'>alert('dd')</script>");
                        Response.Redirect("/");
                    }
                    else
                    {
                        mess += "- Username หรือ Password ไม่ถูกต้อง";
                    }
                }
                else
                {
                    mess += "- Username หรือ Password ไม่ถูกต้อง";
                }
                rs.Close();
                function.Close();
            }

            if (mess != "")
            {
                MsgBox(mess);
            }
            else
            {
                msgBox.Text = "";
            }
        }
Exemple #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 btnStatusUpdate_Command(object sender, CommandEventArgs e)
        {
            cm_id       = e.CommandName;
            Label1.Text = "#" + cm_id;
            string          sql = "SELECT * FROM tbl_cm_detail cm JOIN tbl_device d ON cm.cm_detail_driver_id = d.device_id JOIN tbl_cpoint c ON c.cpoint_id=cm.cm_cpoint WHERE cm.cm_detail_id = '" + cm_id + "'";
            MySqlDataReader rs  = function.MySqlSelect(sql);

            if (rs.Read())
            {
                Label5.Text = rs.GetString("cpoint_name") + " " + rs.GetString("cm_point");
                Label2.Text = rs.GetString("cm_detail_channel");
                Label3.Text = rs.GetString("device_name");
                Label4.Text = rs.GetString("cm_detail_problem");
                if (!rs.IsDBNull(8))
                {
                    txtEDate.Text = rs.GetString("cm_detail_edate");
                }
                else
                {
                    txtEDate.Text = "";
                }
                if (!rs.IsDBNull(9))
                {
                    txtETime.Text = rs.GetString("cm_detail_etime");
                }
                else
                {
                    txtETime.Text = DateTime.Now.ToString("HH.mm");
                }
                if (!rs.IsDBNull(11))
                {
                    txtMethod.Text = rs.GetString("cm_detail_method");
                }
                else
                {
                    txtMethod.Text = "";
                }
                if (!rs.IsDBNull(12))
                {
                    txtNote.Text = rs.GetString("cm_detail_note");
                }
                else
                {
                    txtNote.Text = "";
                }
            }
            rs.Close();
            function.Close();
        }
Exemple #7
0
        private void getStatusAmount(Label label, int status, string year)
        {
            string          sql = "SELECT COUNT(*) AS count_num FROM tbl_claim c JOIN tbl_cpoint ON claim_cpoint = cpoint_id JOIN tbl_status ON status_id = claim_status LEFT JOIN tbl_user ON username = claim_user_start_claim JOIN tbl_status_detail sd ON sd.detail_claim_id = c.claim_id AND sd.detail_status_id = c.claim_status WHERE claim_delete = '0' AND c.claim_status = '" + status + "' AND c.claim_budget_year = '" + year + "'";
            MySqlDataReader rs  = function.MySqlSelect(sql);

            if (rs.Read())
            {
                label.Text = rs.GetString("count_num") + " รายการ";
            }
            else
            {
                label.Text = "0 รายการ";
            }
            rs.Close();
            function.Close();
            function.conn.Close();
        }
Exemple #8
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("");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("/");
            }

            if (!this.IsPostBack)
            {
                string sql = "";
                if (function.CheckLevel("Department", Session["UserPrivilegeId"].ToString()))
                {
                    sql = "SELECT * FROM tbl_cpoint ORDER BY cpoint_id";
                    function.getListItem(txtCpoint, sql, "cpoint_name", "cpoint_id");
                    function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id");
                    txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", ""));
                }
                else
                {
                    sql = "SELECT * FROM tbl_cpoint WHERE cpoint_id = '" + Session["UserCpoint"].ToString() + "'";
                    function.getListItem(txtCpoint, sql, "cpoint_name", "cpoint_id");
                    function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id");
                    //txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", ""));
                }

                string sql_Device = "SELECT * FROM tbl_device ORDER BY device_name";
                function.getListItem(txtDeviceAdd, sql_Device, "device_name", "device_id");
                txtDeviceAdd.Items.Insert(0, new ListItem("", ""));
                txtSTime.Text = DateTime.Now.ToString("HH.mm");
                BindData("");

                if (Request["ref"] != null)
                {
                    txtRef.Value = Request["ref"].ToString();
                    sql          = "SELECT * FROM tbl_cm_detail WHERE cm_detail_id = '" + txtRef.Value + "'";
                    MySqlDataReader rs = function.MySqlSelect(sql);
                    if (rs.Read())
                    {
                        txtCpoint.SelectedValue    = rs.GetString("cm_cpoint");
                        txtPoint.Text              = rs.GetString("cm_point");
                        txtChannel.Text            = rs.GetString("cm_detail_channel");
                        txtSDate.Text              = rs.GetString("cm_detail_sdate");
                        txtSTime.Text              = rs.GetString("cm_detail_stime");
                        txtDeviceAdd.SelectedValue = rs.GetString("cm_detail_driver_id");
                        txtProblem.Text            = rs.GetString("cm_detail_problem");
                        txtNote.Text = rs.GetString("cm_detail_note");
                    }
                    rs.Close();
                    function.Close();

                    btnSaveCM.Visible   = false;
                    btnEditCM.Visible   = true;
                    btnCancelCM.Visible = true;

                    if (function.CheckLevel("Techno", Session["UserPrivilegeId"].ToString()))
                    {
                        btnDeleteCM.Visible = true;
                    }
                    else
                    {
                        btnDeleteCM.Visible = false;
                    }
                }
                else
                {
                    btnSaveCM.Visible   = true;
                    btnEditCM.Visible   = false;
                    btnCancelCM.Visible = false;
                    btnDeleteCM.Visible = false;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                if (Session["UserCpoint"].ToString() != "0")
                {
                    Response.Redirect("/Claim/claimForm");
                }

                if (!this.IsPostBack)
                {
                    if (txtDateOrder.Text == "")
                    {
                        txtDateOrder.Text = DateTime.Now.ToString("dd-MM-") + (DateTime.Now.Year + 543);
                    }
                    if (txtDateSendOrder.Text == "")
                    {
                        txtDateSendOrder.Text = DateTime.Now.ToString("dd-MM-") + (DateTime.Now.Year + 543);
                        txtDateSendOrder_TextChanged(null, null);
                    }
                    PageLoadData();
                    string sql = "SELECT * FROM tbl_company ORDER BY company_name";
                    function.getListItem(txtCompany, sql, "company_name", "company_id");
                    //lbTitle.Text = Session["codePK"].ToString();
                    sql = "SELECT * FROM tbl_quotations q JOIN tbl_company c ON q.quotations_company_id = c.company_id WHERE q.quotations_claim_id = '" + Session["codePK"].ToString() + "' AND quotations_delete = '0'";
                    function.getListItem(txtCompanyOrder, sql, "company_name", "company_id");
                }

                if (int.Parse(Session["status_id"].ToString()) >= 3)
                {
                    if (int.Parse(Session["status_id"].ToString()) != 3)
                    {
                        btnSaveNoteTo.Visible = false;
                    }

                    string[] readText = File.ReadAllLines(HostingEnvironment.MapPath("/Config/") + "ListDocTechno.txt");
                    int      num      = 1;
                    foreach (string s in readText)
                    {
                        if (num != 7)
                        {
                            AddControls(num, num + ". " + s + " จำนวน", Panel1);
                        }
                        else
                        {
                            AddControls(num, num + ". " + s + " " + function.GetSelectValue("tbl_claim_com", "claim_id='" + Session["codePK"].ToString() + "'", "claim_detail_insurer") + " จำนวน", Panel1);
                        }
                        num++;
                    }

                    string          sql_doc = "SELECT * FROM tbl_quotations q JOIN tbl_company c ON c.company_id = q.quotations_company_id WHERE q.quotations_claim_id = '" + Session["codePK"].ToString() + "'";
                    MySqlDataReader rs      = function.MySqlSelect(sql_doc);
                    while (rs.Read())
                    {
                        AddControls(num, num + ". ใบประเมินราคาค่าเสียหาย ของ " + rs.GetString("company_name") + " จำนวน", Panel1);
                        num++;
                    }
                    rs.Close();
                    function.Close();
                    if (!this.IsPostBack)
                    {
                        getDataStatus3();
                    }
                }

                if (int.Parse(Session["status_id"].ToString()) >= 4)
                {
                    getDataStatus4();
                }

                if (int.Parse(Session["status_id"].ToString()) >= 5)
                {
                    getDataStatus5();
                }
            }
        }