Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                if (Session["UserCpoint"].ToString() != "0")
                {
                    Response.Redirect("/Claim/claimForm");
                    //TestGittttxxxx
                    //แก้้้้
                }

                string date = DateTime.Now.ToString("dd-MM") + "-" + (DateTime.Now.Year + 543);

                if (!this.IsPostBack)
                {
                    function.getListItem(txtYear, "SELECT claim_budget_year FROM tbl_claim c GROUP BY claim_budget_year", "claim_budget_year", "claim_budget_year");
                    txtYear.SelectedValue = function.getBudgetYear(date);
                }
                //Response.Redirect("/Claim/claimForm");
                getBind(txtYear.SelectedValue);
            }
        }
Esempio n. 2
0
        protected void btnSaveReport_Click(object sender, EventArgs e)
        {
            string sql_check   = "SELECT * FROM tbl_claim WHERE claim_id='" + Session["CodePK"].ToString() + "'";
            string note_number = "กท./ฝจ./" + txtCpoint.SelectedItem;

            if (txtPoint.Text.Trim().ToLower() != "tsb" && txtPoint.Text.Trim().ToLower() != "")
            {
                note_number += " " + txtPoint.Text.Trim();
            }
            note_number += "/คร./";
            if (note_number == "")
            {
                note_number += "          ";
            }
            else
            {
                note_number += txtCpointNote.Text.Trim();
            }
            note_number += "/" + txtCpointDate.Text.Split('-')[2];

            MySqlDataReader rs = function.MySqlSelect(sql_check);

            if (rs.Read())
            {
                rs.Close();
                function.Close();
                //Update


                string sql = "";
                sql = "Update tbl_claim SET claim_equipment='" + txtEquipment.Text + "'" +
                      ", claim_cpoint='" + txtCpoint.SelectedValue + "'" +
                      ", claim_point='" + txtPoint.Text + "'" +
                      ", claim_cpoint_note='" + note_number + "'" +
                      ", claim_cpoint_date='" + txtCpointDate.Text + "'" +
                      ", claim_start_date='" + txtStartDate.Text + "'" +
                      ", claim_budget_year='" + function.getBudgetYear(txtCpointDate.Text) + "'" +
                      " WHERE claim_id = '" + Session["CodePK"].ToString() + "'";
                if (function.MySqlQuery(sql))
                {
                    string text = "claim_detail_note_to = '" + txtNoteTo.Text + "'" +
                                  ", claim_detail_around='" + txtAround.SelectedItem + "'" +
                                  ", claim_detail_point='" + txtPoint.Text.Trim() + "'" +
                                  ", claim_detail_point='" + txtPoint.Text.Trim() + "'" +
                                  ", claim_detail_time='" + txtTime.Text + "'" +
                                  ", claim_detail_user_alear='" + txtNameAleat.Text + "'" +
                                  ", claim_detail_pos_user_alear='" + txtPosAleat.SelectedItem + "'" +
                                  ", claim_detail_cb='" + txtCB.Text + "'" +
                                  ", claim_detail_cb_claim='" + txtCBClaim.Text + "'" +
                                  ", claim_detail_direction='" + txtDirection.Text + "'" +
                                  ", claim_detail_comefrom = '" + txtComeFrom.Text + "'" +
                                  ", claim_detail_direction_in='" + txtDirectionIn.Text + "'" +
                                  ", claim_detail_accident='" + txtDetail.Text + "'" +
                                  ", claim_detail_supervisor='" + txtSup.Text + "'" +
                                  ", claim_detail_supervisor_pos='" + txtPosSup.SelectedItem + "'" +
                                  ", claim_detail_car='" + txtCar.Text + "'" +
                                  ", claim_detail_license_plate='" + txtLicensePlate.Text + "'" +
                                  ", claim_detail_province='" + txtProvince.Text + "'" +
                                  ", claim_detail_driver='" + txtNameDrive.Text + "'" +
                                  ", claim_detail_idcard='" + txtIdcard.Text + "'" +
                                  ", claim_detail_address='" + txtAddressDriver.Text + "'" +
                                  ", claim_detail_lp2='" + txtLp2.Text + "'" +
                                  ", claim_detail_insurer='" + txtInsurer.Text + "'" +
                                  ", claim_detail_policyholders='" + txtPolicyholders.Text + "'" +
                                  ", claim_detail_clemence='" + txtClemence.Text + "'" +
                                  ", claim_detail_inform='" + txtInform.Text + "'" +
                                  ", claim_detail_tel='" + txtTelDrive.Text + "'";
                    sql = "UPDATE tbl_claim_com SET " + text + " WHERE claim_id = '" + Session["CodePK"].ToString() + "'";
                    if (function.MySqlQuery(sql))
                    {
                        sql = "UPDATE tbl_status_detail SET detail_date_start ='" + txtStartDate.Text + "',detail_date_end ='" + function.ConvertDateTime(txtStartDate.Text, 3) + "' WHERE detail_status_id='1' AND detail_claim_id='" + Session["CodePK"].ToString() + "'";
                        function.MySqlQuery(sql);
                        AlertPop("บันทึกข้อมูลสำเร็จ", "success");
                        //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกข้อมูลสำเร็จ')", true);
                    }
                    else
                    {
                        AlertPop("Error : บันทึกข้อมูลล้มเหลว", "error");
                        //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : บันทึกข้อมูลล้มเหลว')", true);
                    }
                }
                else
                {
                    AlertPop("Error : บันทึกข้อมูลล้มเหลว", "error");
                    //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : บันทึกข้อมูลล้มเหลว')", true);
                }
            }
            else
            {
                rs.Close();
                function.Close();
                //Insert
                string sql = "INSERT INTO tbl_claim ( claim_id, claim_equipment, claim_cpoint, claim_point, claim_cpoint_note, claim_cpoint_date, claim_status, claim_start_date, claim_user_start_claim, claim_user_start_claim_time, claim_delete,claim_budget_year ) VALUES ( '" + Session["CodePK"].ToString() + "', '" + txtEquipment.Text + "', '" + txtCpoint.SelectedValue + "', '" + txtPoint.Text + "', '" + note_number + "', '" + txtCpointDate.Text + "', '1', '" + txtStartDate.Text + "', '" + Session["User"].ToString() + "', NOW(), '0','" + function.getBudgetYear(txtCpointDate.Text) + "')";
                if (function.MySqlQuery(sql))
                {
                    string text   = "";
                    string values = "";
                    text += "claim_id" +
                            ", claim_detail_note_to" +
                            ", claim_detail_point" +
                            ", claim_detail_around" +
                            ", claim_detail_time" +
                            ", claim_detail_user_alear" +
                            ", claim_detail_pos_user_alear" +
                            ", claim_detail_cb" +
                            ", claim_detail_cb_claim" +
                            ", claim_detail_direction" +
                            ", claim_detail_comefrom" +
                            ", claim_detail_direction_in" +
                            ", claim_detail_accident" +
                            ", claim_detail_supervisor" +
                            ", claim_detail_supervisor_pos" +
                            ", claim_detail_car" +
                            ", claim_detail_license_plate" +
                            ", claim_detail_province" +
                            ", claim_detail_driver" +
                            ", claim_detail_idcard" +
                            ", claim_detail_address" +
                            ", claim_detail_lp2" +
                            ", claim_detail_insurer" +
                            ", claim_detail_policyholders" +
                            ", claim_detail_clemence" +
                            ", claim_detail_inform" +
                            ", claim_detail_tel";

                    values += "'" + Session["CodePK"].ToString() + "'" +
                              ", '" + txtNoteTo.Text + "'" +
                              ", '" + txtPoint.Text + "'" +
                              ", '" + txtAround.SelectedItem + "'" +
                              ", '" + txtTime.Text + "'" +
                              ", '" + txtNameAleat.Text + "'" +
                              ", '" + txtPosAleat.SelectedItem + "'" +
                              ", '" + txtCB.Text + "'" +
                              ", '" + txtCBClaim.Text + "'" +
                              ", '" + txtDirection.Text + "'" +
                              ", '" + txtComeFrom.Text + "'" +
                              ", '" + txtDirectionIn.Text + "'" +
                              ", '" + txtDetail.Text + "'" +
                              ", '" + txtSup.Text + "'" +
                              ", '" + txtPosSup.SelectedItem + "'" +
                              ", '" + txtCar.Text + "'" +
                              ", '" + txtLicensePlate.Text + "'" +
                              ", '" + txtProvince.Text + "'" +
                              ", '" + txtNameDrive.Text + "'" +
                              ", '" + txtIdcard.Text + "'" +
                              ", '" + txtAddressDriver.Text + "'" +
                              ", '" + txtLp2.Text + "'" +
                              ", '" + txtInsurer.Text + "'" +
                              ", '" + txtPolicyholders.Text + "'" +
                              ", '" + txtClemence.Text + "'" +
                              ", '" + txtInform.Text + "'" +
                              ", '" + txtTelDrive.Text + "'";

                    sql = "INSERT INTO tbl_claim_com (" + text + ") VALUES (" + values + ")";
                    if (function.MySqlQuery(sql))
                    {
                        sql = "INSERT INTO tbl_status_detail (detail_status_id,detail_claim_id,detail_date_start,detail_date_end) VALUES ('1','" + Session["CodePK"].ToString() + "','" + txtStartDate.Text + "','" + function.ConvertDateTime(txtStartDate.Text, 3) + "')";
                        function.MySqlQuery(sql);
                        AlertPop("บันทึกข้อมูลสำเร็จ", "success");
                        //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกข้อมูลสำเร็จ')", true);
                    }
                    else
                    {
                        AlertPop("Error : บันทึกข้อมูลล้มเหลว", "error");
                        //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : บันทึกข้อมูลล้มเหลว')", true);
                    }
                }
                else
                {
                    AlertPop("Error : บันทึกข้อมูลล้มเหลว", "error");
                    //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : บันทึกข้อมูลล้มเหลว')", true);
                }
            }
        }