protected void btnSaveQuotations_Click(object sender, EventArgs e) { string sql = "INSERT INTO tbl_quotations (quotations_claim_id,quotations_company_id,quotations_company_price,quotations_note_number,quotations_delete,quotations_date_send,quotations_date_recive,quotations_doc_img,quotations_order,quotations_order_img) VALUES ('" + Session["codePK"].ToString() + "','" + txtCompany.SelectedValue + "','0','" + txtNoteNumber.Text + "','0','" + function.ConvertDateTimeEB(DateTime.Now.ToString("dd-MM-yyyy")).ToString("dd-MM-yyyy") + "','0','0','0','0')"; //string script = ""; if (function.MySqlQuery(sql)) { //script = "บันทึกสำเร็จ"; sql = "SELECT * FROM tbl_status_detail WHERE detail_claim_id='" + Session["codePK"].ToString() + "' AND detail_status_id= '2'"; MySqlDataReader rs = function.MySqlSelect(sql); if (!rs.Read()) { rs.Close(); function.Close(); sql = "INSERT INTO tbl_status_detail (detail_status_id,detail_claim_id,detail_date_start,detail_date_end) VALUES ('2','" + Session["codePK"].ToString() + "','" + function.ConvertDateTimeEB(DateTime.Now.ToString("dd-MM-yyyy")).ToString("dd-MM-yyyy") + "','" + function.ConvertDateTime(function.ConvertDateTimeEB(DateTime.Now.ToString("dd-MM-yyyy")).ToString("dd-MM-yyyy"), Quotations) + "')"; if (function.MySqlQuery(sql)) { sql = "UPDATE tbl_claim SET claim_status = '2' WHERE claim_id = '" + Session["codePK"].ToString() + "'"; function.MySqlQuery(sql); } } rs.Close(); function.Close(); txtNoteNumber.Text = ""; txtCompany.SelectedIndex = 0; Response.Redirect("/Techno/TechnoFormDetail"); } BindConpaney(); //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('" + script + "')", true); }
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); } } }