protected void btn_delete_Click(object sender, EventArgs e) { try { if (SysFunc.IsExist("RefundPayment", txtRefundCode.Text, "PaymentReceiptMaster", Session["DealerCode"].ToString())) { SysFuncs.UserMsg(success_add_item, Color.Red, "You Can Not Delete it exist in PaymentReceipt"); return; } if (SysFunc.CheckVoucherPostFlag(Session["DealerCode"].ToString(), txtVoucherNo.Text)) { SysFuncs.UserMsg(success_add_item, Color.Red, "Can't Edit or Delete the Voucher '" + txtVoucherNo.Text + "' is already Posted"); return; } SqlParameter[] PmtRecMaster_param = { /*0*/ new SqlParameter("@DealerCode", SqlDbType.Char, 5), /*1*/ new SqlParameter("@ReceiptNo", SqlDbType.Char, 8) }; PmtRecMaster_param[0].Value = Session["DealerCode"].ToString(); PmtRecMaster_param[1].Value = txtRefundCode.Text; if (SysFuncs.ExecuteSP_NonQuery("[sp_W2_PaymentRefund_Master_Delete]", PmtRecMaster_param)) { SysFunc.UpdateJV(Session["DealerCode"].ToString(), txtVoucherNo.Text); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "Deletealert()", true); } } catch (Exception ex) { SysFuncs.UserMsg(success_add_item, Color.Red, ex.Message); return; } }
protected void btnSave_Click(object sender, EventArgs e) { if (myFunc.CodeExists("JobCardMaster", "EngineNo", txtEngNo.Text.Trim(), " And GatePass='' ")) { lblMSG.Text = "Can not update this Engine number use in Job Card " + txtEngNo.Text; PopupControlMSG.ShowOnPageLoad = true; return; } else { lblMasg.Text = ""; } if (myFunc.CodeExists("JobCardMaster", "ChassisNo", txtChassisNo.Text.Trim(), " And GatePass='' ")) { lblMSG.Text = "Can not update this Chassis number use in Job Card " + txtChassisNo.Text; PopupControlMSG.ShowOnPageLoad = true; return; } else { lblMasg.Text = ""; } //TextBox[] textBoxes = { txtCustomerCode, txtEndUser, txtRegDate, txtRegNo, txtEngineNo, txtChassisNo, txtProduct, txtInvoiceNo, txtInvoiceDate }; if (txtCustomerName.Text.Trim() == "" || txtEndUserName.Text.Trim() == "" || txtChassisNo.Text.Trim() == "" || txtEngNo.Text.Trim() == "") { return; } else { /// Validate from SMIS Database of Engine number /// DataSet dsValidate = new DataSet(); DateTime InvDate = dpInvoiceDate.Date; if (cmbBrand.Value.ToString().Trim() == "001") { //if (InvDate >= Convert.ToDateTime("2009-10-01")) //{ // SqlParameter[] paramData = { // new SqlParameter("@EngineNo",SqlDbType.VarChar,5), // new SqlParameter ("@Chk" ,SqlDbType.Char,1) // }; // paramData[0].Value = txtEngNo.Text; // paramData[1].Value = "Y"; // dsValidate = SqlHelper.ExecuteDataset(GlobalVar.mCon, "sp_2W_Get_NewVehicleInfo_SDMS", paramData); // if (dsValidate.Tables[0].Rows.Count > 0) // { // if (dsValidate.Tables[0].Rows[0]["ChasisNo"].ToString() != txtChassisNo.Text.Trim()) // { // lblMSG.Text = "Enter valid Chassis No."+ txtChassisNo.Text; // PopupControlMSG.ShowOnPageLoad = true; // return; // } // if (dsValidate.Tables[0].Rows[0]["ProdCode"].ToString() != cmbProdCode.Text.Trim()) // { // lblMSG.Text = "Enter valid Product Code." + cmbProdCode.Text; // PopupControlMSG.ShowOnPageLoad = true; // return; // } // //if(txtInvoiceNo.Text .Trim () > // //if (dsValidate.Tables[0].Rows[0]["InvoiceNo"].ToString() != txtInvoiceNo.Text.Trim()) // //{ // // grl.UserMsg(lblMasg, Color.Red, "Enter valid InvoiceNo.", txtInvoiceNo ); // // return; // //} // //if (Convert.ToDateTime (dsValidate.Tables[0].Rows[0]["InvoiceDate"].ToString ()).ToString ("dd/MM/yyyy") != InvDate.ToString ("dd/MM/yyyy")) // //{ // // grl.UserMsg(lblMasg, Color.Red, "Enter valid InvoiceDate.", txtInvoiceDate ); // // return; // //} // if (dsValidate.Tables[0].Rows[0]["VersionCode"].ToString() != txtVersion.Text) // { // lblMSG.Text = "Enter valid Version Code" + txtVersion.Text; // PopupControlMSG.ShowOnPageLoad = true; // return; // } // } // else // { // lblMSG.Text = "Enter valid Engine No." + txtEngNo.Text; // PopupControlMSG.ShowOnPageLoad = true; // return; // } //} } //////////////////////////////////////////////// SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.VarChar, 5), //0 new SqlParameter("@CusCode", SqlDbType.VarChar, 8), //1 new SqlParameter("@EndUserCode", SqlDbType.Char, 8), //2 new SqlParameter("@CtdDate", SqlDbType.DateTime), //3 new SqlParameter("@RegNo", SqlDbType.VarChar, 15), //4 new SqlParameter("@ChassisNo", SqlDbType.VarChar, 30), //5 new SqlParameter("@EngineNo", SqlDbType.VarChar, 30), //6 new SqlParameter("@BrandCode", SqlDbType.Char, 3), //7 new SqlParameter("@ProdCode", SqlDbType.VarChar, 10), //8 new SqlParameter("@VersionCode", SqlDbType.Char, 3), //9 new SqlParameter("@ColorCode", SqlDbType.Char, 5), //10 new SqlParameter("@InvoiceNo", SqlDbType.VarChar, 25), //11 new SqlParameter("@InvoiceDate", SqlDbType.DateTime), //12 new SqlParameter("@InsCompCode", SqlDbType.Char, 4), //13 new SqlParameter("@InsPolicyNo", SqlDbType.VarChar, 25), //14 new SqlParameter("@LossNo", SqlDbType.VarChar, 15), //15 new SqlParameter("@MeterReading", SqlDbType.VarChar, 10), //16 new SqlParameter("@MonthReading", SqlDbType.VarChar, 4), //17 new SqlParameter("@Remarks", SqlDbType.VarChar, 100), //18 new SqlParameter("@UpdUser", SqlDbType.VarChar, 30), //19 new SqlParameter("@UpdTerm", SqlDbType.VarChar, 30) //20 }; // 101 = Not Available // 102 = Not Understand param[0].Value = Session["DealerCode"].ToString(); param[1].Value = cmbCustomerCode.Text.Trim().ToUpper(); param[2].Value = cmbEndUser.Text.Trim().ToUpper(); param[3].Value = myFunc.SaveDate(dpRegDate.Text); param[4].Value = txtRegNo.Text.Trim().ToUpper().ToUpper(); param[5].Value = txtChassisNo.Text.Trim().ToUpper(); param[6].Value = txtEngNo.Text.Trim().ToUpper(); param[7].Value = cmbBrand.Value.ToString().Trim(); param[8].Value = cmbProdCode.Text.Trim(); param[9].Value = txtVersion.Text.Trim(); param[10].Value = cmbColorCode.Text.Trim(); param[11].Value = txtInvoiceNo.Text.Trim(); param[12].Value = myFunc.SaveDate(dpInvoiceDate.Text); param[13].Value = cmbInsCode.Text.Trim(); param[14].Value = txtPolicyNo.Text.Trim(); param[15].Value = "102"; // new SqlParameter("@LossNo",SqlDbType.VarChar,15), param[16].Value = "101"; // new SqlParameter("@MeterReading",SqlDbType.VarChar,10), param[17].Value = "101"; // new SqlParameter("@MonthReading",SqlDbType.VarChar,4), param[18].Value = "101"; // new SqlParameter("@Remarks",SqlDbType.VarChar,100), param[19].Value = Session["UserName"].ToString().ToUpper(); param[20].Value = Environment.MachineName; //select * from brand where BrandCode='' //select * from version Where Version='' //select * from customer where CusCode='' //select * from vehicle where BrandCode=='' and ProdCode='' and VersionCode='' and ColorCode //select * from color where ColorCode = '' try { if ((myFunc.IsExist("CusCode", cmbCustomerCode.Text, "Customer", Session["DealerCode"].ToString()) == true)) { if ((myFunc.IsExist("BrandCode", cmbBrand.Value.ToString(), "Brand", Session["DealerCode"].ToString()) == true)) { if ((myFunc.IsExist("VersionCode", txtVersion.Text, "Vehicle", Session["DealerCode"].ToString()) == true)) { // apStr = " and versioncode=" + txtVersion.Text + " and ProdCode='" + txtProduct.Text + "'"; if ((myFunc.IsExist("ColorCode", cmbColorCode.Text, "Vehicle", Session["DealerCode"].ToString()) == true)) { if (!myFunc.IsExist("RegNo", txtRegNo.Text, "CustomerVehicle", Session["DealerCode"].ToString()) & !myFunc.IsExist("ChassisNo", txtChassisNo.Text, "CustomerVehicle", Session["DealerCode"].ToString()) & !myFunc.IsExist("EngineNo", txtEngNo.Text, "CustomerVehicle", Session["DealerCode"].ToString())) { if (myFunc.ExecuteSP_NonQuery("sp_CustomerVehicle_Insert", param)) { lblMSG.Text = "Record Saved!" + txtVersion.Text; PopupControlMSG.ShowOnPageLoad = true; GetDataLoaded(true, false); btnDelete.Enabled = true; } else { lblMSG.Text = "Record Not Saved!"; PopupControlMSG.ShowOnPageLoad = true; } } else { apStr = " and ChassisNo ='" + txtChassisNo.Text + "' and jobstatus = null and GatePass = null"; if (myFunc.IsExist("ChassisNo", txtChassisNo.Text, "JobCardMaster", Session["DealerCode"].ToString()) & myFunc.IsExist("EngineNo", txtEngNo.Text, "JobCardMaster", Session["DealerCode"].ToString())) { if (myFunc.IsExist("ChassisNo", txtChassisNo.Text, "JobCardMaster", Session["DealerCode"].ToString(), apStr)) { lblMSG.Text = "Record can not be updated"; PopupControlMSG.ShowOnPageLoad = true; return; } else { if (myFunc.ExecuteSP_NonQuery("sp_CustomerVehicle_Update", param)) { // objMBLL.ShowMessageBox("Record Updated", txtCustomerCode); lblMSG.Text = "Record Updated"; PopupControlMSG.ShowOnPageLoad = true; GetDataLoaded(true, false); } else { lblMSG.Text = "Record Not updated"; PopupControlMSG.ShowOnPageLoad = true; } } } else { if (myFunc.ExecuteSP_NonQuery("sp_CustomerVehicle_Update", param)) { //objMBLL.ShowMessageBox("Record Updated", txtCustomerCode); lblMSG.Text = "Record updated"; PopupControlMSG.ShowOnPageLoad = true; GetDataLoaded(true, false); } else { lblMSG.Text = "Record can not be updated"; PopupControlMSG.ShowOnPageLoad = true; } } } } } else { //objMBLL.ShowMessageBox("'Version' not exist! ", txtCustomerCode); lblMSG.Text = "Version not exist"; PopupControlMSG.ShowOnPageLoad = true; } } else { lblMSG.Text = "Product not exist!"; PopupControlMSG.ShowOnPageLoad = true; } } else { lblMSG.Text = "Brand not exist"; PopupControlMSG.ShowOnPageLoad = true; } } catch (Exception ex) { var LineNumber = new StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); lblMSG.Text = "Error : " + ex.Message + "/" + ex.StackTrace.ToString() + "/" + LineNumber.ToString(); PopupControlMSG.ShowOnPageLoad = true; } } }
protected void btnDelete_Click(object sender, EventArgs e) { //SqlTransaction Trans = null; if (ddlAppSt.SelectedValue == "Approved") { lblMsg.Visible = true; lblMsg.ForeColor = Color.Red; lblMsg.Text = "Cannot Delete Approved Status"; return; } bool Chek = false; try { //TextBox[] textBoxes = { txtPPRNo }; //if (!MasterValidation(textBoxes)) //{ // return; //} if (sysFuncs.IsPosted("PPRMaster", "PPRCode", ddlPRNo.SelectedValue, string.Empty)) { sysFuncs.UserMsg(lblMsg, Color.Red, "Can not Delete PPR is posted", null); return; } //if (ObjGenral.IsDelFlag("PPRMaster", "PPRCode", txtPPRNo.Text, string.Empty) == false) //{ // ObjGenral.UserMsg(lblMsg, Color.Red, "Record dose not exist", null); // return; //} if (ddlPRNo.SelectedValue != "__/_____") { if (sysFuncs.IsExist("PPRCode", ddlPRNo.SelectedValue, "PPRMaster", string.Empty) == false) { lblMsg.Text = "Record dose not exist"; //sysFuncs.UserMsg(lblMsg, Color.Red, "Record dose not exist", ddlPRNo.SelectedValue); return; } } //if (ObjTrans.BeginTransaction(ref Trans) == false) //{ // return; //} SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), //0 new SqlParameter("@PPRCode", SqlDbType.Char, 8), //1 }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = ddlPRNo.SelectedValue; if (sysFuncs.ExecuteSP_NonQuery("sp_2W_Service_DeletePPR", param)) { sysFuncs.UserMsg(lblMsg, Color.Green, "Deleted Successfully", null); ClearAll(); } } catch (Exception ex) { lblMsg.Visible = true; lblMsg.ForeColor = Color.Red; lblMsg.Text = ex.Message; //SendAlert("Error: " + ex.Message); } }