protected void BtnDelete_Click(object sender, EventArgs e) { if (!sec.UserRight("2540", "004")) { Response.Redirect("~/Test.aspx"); } string StrPartsTransLocCode = ""; bool Check = false; TextBox[] textBoxes = { txtAutoPartLocCode, txtAutoPartsSubLocCode, txtPartsTransLocCode }; if (!MasterValidation(textBoxes)) { return; } try { StrPartsTransLocCode = txtAutoPartLocCode.Text + txtAutoPartsSubLocCode.Text + txtPartsTransLocCode.Text; if (SysFunc.CodeExists("ItemStock", "PartsTransLocCode", StrPartsTransLocCode)) { SysFunc.UserMsg(LbErr, Color.Red, "Can not delete location its used in ItemStock", txtPartsTransLocCode); return; } if (SysFunc.CodeExists("ItemStatus", "PartsTransLocCode", StrPartsTransLocCode)) { SysFunc.UserMsg(LbErr, Color.Red, "Can not delete location its used in ItemStatus", txtPartsTransLocCode); return; } if (SysFunc.CodeExists("GRNDetail", "PartsTransLocCode", StrPartsTransLocCode)) { SysFunc.UserMsg(LbErr, Color.Red, "Can not delete location its used in GRNDetail", txtPartsTransLocCode); return; } SqlParameter[] param = { new SqlParameter("@DealerCode", Session["DealerCode"].ToString()), //0 new SqlParameter("@PartsTransLocCode", StrPartsTransLocCode) //1 }; Check = SysFunc.SP_Spare_Delete_PartsTransLocation(param); GVTransLocFill(); txtPartsTransLocCode.Text = string.Empty; txtPartsTransLocDesc.Text = string.Empty; } catch (Exception ex) { SysFunc.UserMsg(LbErr, Color.Red, "Error :" + ex.Message); } }
private void ViewJobCardData() { DataSet ds = new DataSet(); SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), new SqlParameter("@JobCardCode", SqlDbType.Char, 8), }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = txtJobCode.Text; ds = sysFuncs.FillDataSet("sp_2W_Service_Select_JobCardMaster", param); if (ds.Tables[0].Rows.Count > 0) { txtRegNo.Text = ds.Tables[0].Rows[0]["RegNo"].ToString(); txtChasisNo.Text = ds.Tables[0].Rows[0]["ChassisNo"].ToString(); txtEngNo.Text = ds.Tables[0].Rows[0]["EngineNo"].ToString(); txtVehModel.Text = ds.Tables[0].Rows[0]["InvoiceDate"].ToString().Substring(6, 4); txtVehColor.Text = ds.Tables[0].Rows[0]["ColorCode"].ToString(); txtInvDate.Text = ds.Tables[0].Rows[0]["InvoiceDate"].ToString(); txtCustCode.Text = ds.Tables[0].Rows[0]["CusCode"].ToString(); txtProdCode.Text = ds.Tables[0].Rows[0]["ProdCode"].ToString(); txtInvoiceNo.Text = ds.Tables[0].Rows[0]["InvoiceNo"].ToString(); ds = new DataSet(); //Uzair if (sysFuncs.CodeExists("Customer", "CusCode", txtCustCode.Text, "")) { txtCustName.Text = ds.Tables[0].Rows[0]["CusDesc"].ToString(); } } }
protected void btnSave_Click(object sender, EventArgs e) { try { DataSet ds = new DataSet(); if (myFunc.CodeExists("Customer", "DealerCode='" + Session["DealerCode"].ToString() + "' And CusCode='" + ddCustomerCode.Text + "' And NIC='" + txtNICNo.Text + "'", Session["DealerCode"].ToString()) == false) { string chkCNIC = string.Empty; ds = new DataSet(); myFunc.ExecuteQuery("Select * From Customer Where DealerCode='" + Session["DealerCode"].ToString() + "' And CusCode<>'" + ddCustomerCode.Text + "'", ref ds); if (ds.Tables[0].Rows.Count != 0) { //if (ds.Tables[0].Rows[0]["NIC"].ToString().Trim() != string.Empty) //{ foreach (DataRow dtRow in ds.Tables[0].Rows) { if (dtRow["NIC"].ToString().Trim() != string.Empty) { if (dtRow["NIC"].ToString() == txtNICNo.Text.Trim()) { //ObjGenral.UserMsg(lblMsg, Color.Red, "CNIC Number is already exist", txtNIC); lblMSG.Text = txtNICNo.Text + " CNIC Number is already exist"; PopupControlMSG.ShowOnPageLoad = true; chkCNIC = "Y"; break; } } } if (chkCNIC == "Y") { return; } // } } } if (InsertCustomer()) { if (ddCustomerCode.Text == "") { lblMSG.Text = "Customer add successfully (" + AutoGenCode + ")"; } else { lblMSG.Text = "Customer information updated"; } PopupControlMSG.ShowOnPageLoad = true; btnClear_Click(btnClear, EventArgs.Empty); //lblMsg.Text = "Customer Add Successfully '" + AutoGenCode + "'"; //lblMsg.ForeColor = Color.Green; //ClearAll(); } } catch (Exception ex) { SendAlert("Error:" + ex.ToString()); } }
protected void btnDeleteMain_Click(object sender, EventArgs e) { // delete if (myFunc.CodeExists("PartsSubLocation", "PartsLocCode", txtLocCode.Text.Trim(), this.Session["DealerCode"].ToString())) { lblMSG.Text = "Can't delete , this code exist in sub location ."; PopupControlMSG.ShowOnPageLoad = true; return; } string sql = "delete from PartsLocation where PartsLocCode='" + txtLocCode.Text.Trim() + "'"; myFunc.GetData(sql); lblMSG.Text = "Location has been deleted"; PopupControlMSG.ShowOnPageLoad = true; txtLocCode.Text = ""; txtLocCode_TextChanged(txtLocCode, EventArgs.Empty); }
protected void btnPost_Click(object sender, EventArgs e) { if (!sec.UserRight("2583", "005")) { Response.Redirect("~/Test.aspx"); } if (txtLabPST.Text == "") { string script = "alert(\"PST Amount should not left blank !!!\");"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ServerControlScript", script, true); } if (txtGSTAmt.Text == "") { string script = "alert(\"GST Amount should not left blank !!!\");"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ServerControlScript", script, true); } else { double PST = double.Parse(txtLabPST.Text.Replace(" ", "").Trim() == "" ? "0" : txtLabPST.Text.Replace(" ", "").Trim()); double GST = double.Parse(txtGSTAmt.Text.Replace(" ", "").Trim() == "" ? "0" : txtGSTAmt.Text.Replace(" ", "").Trim()); string SSTNo, GSTNo; if (ObjGenral.CodeExists("PSTUniqueSalesTaxInvoice", "SSTSalesTaxInvNO", txtPSTCode.Text, "")) { lblMessage.Text = "Already Code exists against this Dealer "; if (ObjGenral.CodeExists("UniqueSalesTaxInvoice", "SalesTaxInvNO", txtGSTCode.Text, "")) { lblMessage.Text = "Already Code exists against this Dealer "; } } else { if (PST > 0 && GST > 0) { SSTNo = ObjGenral.AutoGen("PSTUniqueSalesTaxInvoice", "SSTSalesTaxInvNo", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy")); GSTNo = ObjGenral.AutoGen("UniqueSalesTaxInvoice", "SalesTaxInvNO", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy")); SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), //0 new SqlParameter("@FPBillNo", SqlDbType.Char, 8), //1 new SqlParameter("@SSTNo", SqlDbType.VarChar, 8), //0 new SqlParameter("@SSTDate", SqlDbType.DateTime), //1 new SqlParameter("@SSTAmount", SqlDbType.Decimal), //1 new SqlParameter("@GSTNo", SqlDbType.VarChar, 8), //0 new SqlParameter("@GSTDate", SqlDbType.DateTime), //1 new SqlParameter("@GSTAmount", SqlDbType.Decimal), //1 }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = ddlBillingNo.SelectedValue; param[2].Value = SSTNo; param[3].Value = DateTime.Now.ToString(); param[4].Value = Convert.ToDecimal(txtLabPST.Text); param[5].Value = GSTNo; param[6].Value = DateTime.Now.ToString(); param[7].Value = Convert.ToDecimal(txtGSTAmt.Text); ObjGenral.ExecuteSP_NonQuery("sp_2W_Service_UpdateSSTNoDate_JENBillMaster", param); lblPstCode.Text = "Pst Code " + SSTNo.ToString() + " " + "has been generated sucessfully !!"; lblGstCode.Text = "Gst Code " + GSTNo.ToString() + " " + "has been generated sucessfully !!"; ClearAll(); } else { lblPstCode.Text = "PST and GST amount Must be greater than zero cannot be generated !!!"; } } } }
protected void txtEngNo_TextChanged(object sender, EventArgs e) { ds = new DataSet(); DataTable dt = new DataTable(); search_result = false; txtEngNo.ToolTip = ""; try { if (txtEngNo.Text.Count() < 6) { lblMSG.Text = "6 Characters must be enter in Engine number"; PopupControlMSG.ShowOnPageLoad = true; return; } else { lblMasg.Text = ""; } SqlParameter[] paramData = { new SqlParameter("@EngineNo", SqlDbType.VarChar, 5), new SqlParameter("@Chk", SqlDbType.Char, 1) }; if (txtEngNo.Text == "") { return; } else { if (cmbBrand.Value.ToString().Trim() == "001") { txtChassisNo.Text = ""; cmbProdCode.Text = ""; txtVersion.Text = ""; cmbColorCode.Text = ""; txtInvoiceNo.Text = ""; dpInvoiceDate.Text = ""; txtProdDesc.Text = ""; txtColorName.Text = ""; if (myFunc.CodeExists("customervehicle", "EngineNo", txtEngNo.Text.Trim(), ref ds, Session["DealerCode"].ToString())) { txtRegNo.Text = ds.Tables[0].Rows[0]["RegNo"].ToString(); dpRegDate.Text = ds.Tables[0].Rows[0]["tdDate"].ToString(); txtChassisNo.Text = ds.Tables[0].Rows[0]["ChassisNo"].ToString(); cmbProdCode.Text = ds.Tables[0].Rows[0]["ProdCode"].ToString(); txtProdDesc.Text = myFunc.GetStringValuesAgainstCodes("ProdCode", cmbProdCode.Text, "ProdDesc", "Vehicle"); cmbColorCode.Text = ds.Tables[0].Rows[0]["ColorCode"].ToString(); txtColorName.Text = myFunc.GetStringValuesAgainstCodes("ProdCode", cmbProdCode.Text, "Color", "Vehicle"); FillProduct(ds); } else { paramData[0].Value = txtEngNo.Text; paramData[1].Value = "Y"; //ds = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(GlobalVar.mDataConnection, "sp_2W_Get_NewVehicleInfo_SDMS", paramData); dt = myFunc.GetData("select * from customervehicle where EngineNo='" + txtEngNo.Text + "'"); ds.Tables.Add(dt); if (ds.Tables[0].Rows.Count > 0) { txtChassisNo.Text = ds.Tables[0].Rows[0]["ChasisNo"].ToString(); cmbProdCode.Text = ds.Tables[0].Rows[0]["ProdCode"].ToString(); txtProdDesc.Text = ds.Tables[0].Rows[0]["ProdDesc"].ToString(); txtColorName.Text = ds.Tables[0].Rows[0]["ColorDesc"].ToString(); FillProduct(ds); if (txtColorName.Text.Trim() == "NoColor") { txtColorName.Text = "BLACK"; cmbColorCode.Text = "00002"; } else { if (myFunc.CodeExists("Vehicle", "ProdCode='" + cmbProdCode.Text.Trim() + "' AND Color='" + txtColorName.Text.Trim() + "'", ref ds)) { cmbColorCode.Text = ds.Tables[0].Rows[0]["ColorCode"].ToString(); } } } else { lblMSG.Text = "Record Not found " + txtEngNo.Text; PopupControlMSG.ShowOnPageLoad = true; } } if (search_result == false) { paramData[0].Value = txtEngNo.Text; paramData[1].Value = "N"; //ds = SqlHelper.ExecuteDataset(this.StrMCDMainDBCon, "sp_2W_Get_NewVehicleInfo_SDMS", paramData); dt = myFunc.GetData("select * from customervehicle where EngineNo='" + txtEngNo.Text + "'"); ds.Tables.Add(dt); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { txtEngNo.ToolTip = txtEngNo.ToolTip + ds.Tables[0].Rows[i]["EngineNo"].ToString() + System.Environment.NewLine; } } txtEngNo.Focus(); } } } catch (Exception ex) { throw ex; } }
private void Posting(ref bool Check) { SqlTransaction Trans = null; string strSQL = string.Empty; DataSet dsItemStock = new DataSet(); string strMaster = string.Empty; Check = false; string strSrNo = string.Empty; try { if (GvMain.Rows.Count == 0) { SysFunc.UserMsg(LbErr, Color.Red, "Details should not be left blank..."); return; } else { LbErr.Text = string.Empty; } ///Transection Begin if (ObjTrans.BeginTransaction(ref Trans) == false) { return; } //if (ddl) //{ Save_InsertMasterDetail(Trans, ref Check, ref strSrNo); if (Check == true) { ///Start Posting foreach (GridViewRow gvr in GvMain.Rows) { //'<<<<<<<< Update the ItemSotck >>>>>>>>>>> bool NewFlag = false; Label LbItemCode = (Label)gvr.FindControl("LbItemCode"); Label LbQty = (Label)gvr.FindControl("LbQty"); Label LbAmt = (Label)gvr.FindControl("LbAmount"); HiddenField hdLocCode = (HiddenField)gvr.FindControl("HDPartsTransLocCode"); strSQL = "SELECT * From ItemStock where ItemCode = '" + LbItemCode.Text + "' AND PartsTransLocCode = '" + hdLocCode.Value + "'"; if (SysFunc.ExecuteQuery(strSQL, ref dsItemStock) == false) { NewFlag = true; } if (NewFlag) { strSQL = "INSERT into ItemStock(DealerCode, PartsTransLocCode, ItemCode, RetQty, RetVal,SaleVal,SaleQty,RetSupp,Rejqty,IssVal,IssQty,RecVal,RecQty) values (" + " '" + Session["DealerCode"].ToString() + "'," + " '" + hdLocCode.Value + "'," + " '" + LbItemCode.Text + "'," + " '" + LbQty.Text.Trim() + "'," + " '" + LbAmt.Text + "',0,0,0,0,0,0,0,0) "; } else { strSQL = "UPDATE ItemStock Set RetQty = RetQty + " + LbQty.Text.Trim() + ", RetVal = RetVal + " + LbAmt.Text + " Where DealerCode = '" + Session["DealerCode"].ToString() + "' AND PartsTransLocCode = '" + hdLocCode.Value + "' And ItemCode = '" + LbItemCode.Text + "'"; } if (SysFunc.ExecuteQuery_NonQuery(strSQL, Trans) == false) { SysFunc.UserMsg(LbErr, Color.Red, "Can Not Post, Not found ItemStock"); ObjTrans.RollBackTransaction(ref Trans); Check = false; return; } strSQL = "UPDATE StockIssueDetail SET RetQty=" + LbQty.Text.Trim() + " WHERE Dealercode='" + Session["DealerCode"].ToString() + "' And IssueNo='" + txtIssueNo.Text.Trim() + "' And ItemCode='" + LbItemCode.Text.Trim() + "'"; if (SysFunc.ExecuteQuery_NonQuery(strSQL, Trans) == false) { SysFunc.UserMsg(LbErr, Color.Red, "Can Not Post, Not found ItemStock"); ObjTrans.RollBackTransaction(ref Trans); Check = false; return; } } //for adjust customer outstanding if (rdCounterSale.Checked) { strMaster = "Update CounterSaleMaster set InvoiceAmount = InvoiceAmount - '" + txtTotalAmount.Text + "' Where saleinvno='" + ddlSaleInvNo.SelectedValue.ToString() + "' and DealerCode = '" + Session["DealerCode"].ToString() + "'"; if (SysFunc.ExecuteQuery_NonQuery(strMaster, Trans) == false) { SysFunc.UserMsg(LbErr, Color.Red, "Can Not Post, Not found ItemStock"); ObjTrans.RollBackTransaction(ref Trans); Check = false; return; } } if (rdJobCard.Checked) { if (SysFunc.CodeExists("CustomerInvoice", "JobcardCode", ddlSaleInvNo.SelectedValue.ToString(), " And DelFlag = 'N' and invType in ('Inv','Clb')") == true) { strMaster = "Update CustomerInvoice set NetAmountCustomer = NetAmountCustomer - '" + txtTotalAmount.Text + "' Where jobcardCode='" + ddlSaleInvNo.SelectedValue.ToString() + "' and DealerCode = '" + Session["DealerCode"].ToString() + "' and invType in ('Inv','Clb')"; if (SysFunc.ExecuteQuery_NonQuery(strMaster, Trans) == false) { SysFunc.UserMsg(LbErr, Color.Red, "Can Not Post, Not found ItemStock"); ObjTrans.RollBackTransaction(ref Trans); Check = false; return; } } } if (UpdatePost(strSrNo, ref Trans) == false) { SysFunc.UserMsg(LbErr, Color.Red, "UpdatePost Error"); ObjTrans.RollBackTransaction(ref Trans); Check = false; return; } else { Check = true; } } if (Check == false) { ObjTrans.RollBackTransaction(ref Trans); SysFunc.UserMsg(LbErr, Color.Red, "Record can not save. Try again..."); } else { ObjTrans.CommittTransaction(ref Trans); SysFunc.UserMsg(LbErr, Color.Green, "Record Posted successfuly. Return No.: " + strSrNo); Load_ddlSRNo(); CtlClear("T"); } } catch (Exception ex) { ObjTrans.RollBackTransaction(ref Trans); SysFunc.UserMsg(LbErr, Color.Red, ex.Message); } }