protected void btnUpdate_Click(object sender, EventArgs e) { bool msg = false; string message = string.Empty; try { FinishedProductProvider sendToHOProvider = SendFPToHOEntity(); List <FinishedProductProvider> finishedProductProviderList = SendFPToHODetailEntityList(); if ((finishedProductProviderList == null) || (finishedProductProviderList.Count == 0)) { MessageHelper.ShowAlertMessage("Please select at least one product for purchase"); return; } msg = sendToHOProvider.UpdateFPToHeadOffice(finishedProductProviderList); } catch (Exception ex) { message = ex.Message; } if (msg) { Clear(); this.AlertSuccess(lblMsg, MessageConstants.Updated); } else { MessageHelper.ShowAlertMessage(message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AddBlankRowTogvPurchaseProduct(); txtReceivedDate.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now); btnAddNewChallan.Visible = false; } else { Page.ClientScript.GetPostBackEventReference(this, String.Empty); String eventTarget = Request["__EVENTTARGET"].IsNullOrEmpty() ? String.Empty : Request["__EVENTTARGET"]; if (Request["__EVENTTARGET"] == "SearchPriceSetup") { var requisitionProvider = new FinishedProductProvider(); string batchNRefNo = Request["__EVENTARGUMENT"]; char[] splitchar = { ',' }; string[] batchNRefNoSpliting = batchNRefNo.Split(splitchar); string batchNo = batchNRefNoSpliting[0].ToString(); refNo = batchNRefNoSpliting[1].ToString(); DataTable dt = requisitionProvider.GetByBatchNRef(batchNo, refNo); if (dt.IsNotNull()) { PopulateControls(dt); } } } Session["Value"] = ddlDivision.SelectedValue; }
protected void btnUpdate_Click(object sender, EventArgs e) { mode = "Update"; bool msg = false; string message = string.Empty; string permisionMessage = CheckUserAuthentication(mode); if (String.IsNullOrEmpty(permisionMessage) && string.IsNullOrEmpty(statusMessage)) { try { FinishedProductProvider requisitionProvider = RequisitionInfoEntity(); msg = requisitionProvider.Update(); } catch (Exception ex) { message = ex.Message; } if (msg) { Clear(); this.AlertSuccess(lblMsg, MessageConstants.Updated); } else { MessageHelper.ShowAlertMessage(message); } } else { MessageHelper.ShowAlertMessage(permisionMessage + statusMessage); } }
public bool SendFPToHeadOffice(FinishedProductProvider SendToHOProvider, List <FinishedProductProvider> FinishedProductProviderList, out string challanNo) { bool IsSave = false; try { SqlCommand command = new SqlCommand(); this.ConnectionOpen(); command.Connection = Connection; this.BeginTransaction(true); command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.SendFPToHoSet; SqlParameter t = new SqlParameter("@ChallanNo", SqlDbType.VarChar); t.Direction = ParameterDirection.Output; t.Size = 16; command.Parameters.Add(t); SqlParameter id = new SqlParameter("@ID", SqlDbType.Int); id.Direction = ParameterDirection.Output; command.Parameters.Add(id); command.Parameters.Add("@ChallanDate", SqlDbType.DateTime).Value = SendToHOProvider.ChallanDate; command.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = SendToHOProvider.DivisionID; command.Parameters.Add("@EntryUserID", SqlDbType.Int).Value = SendToHOProvider.EntryUserID; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; command.ExecuteNonQuery(); challanNo = (string)command.Parameters["@ChallanNo"].Value; int ChallanID = (int)command.Parameters["@ID"].Value; foreach (FinishedProductProvider FinishedProductDetailProvider in FinishedProductProviderList) { command = new SqlCommand(); command.Connection = Connection; command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.SendFPToHoDetailSet; command.Parameters.Add("@ChallanID", SqlDbType.Int).Value = ChallanID; command.Parameters.Add("@ProductID", SqlDbType.Int).Value = FinishedProductDetailProvider.ProductID; command.Parameters.Add("@BatchNo", SqlDbType.VarChar).Value = FinishedProductDetailProvider.BatchNo; command.Parameters.Add("@BatchQuantity", SqlDbType.Decimal).Value = FinishedProductDetailProvider.BatchQuantity; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; command.ExecuteNonQuery(); } this.CommitTransaction(); this.ConnectionClosed(); IsSave = true; } catch (Exception exp) { this.RollbackTransaction(); throw new Exception(exp.Message); } finally { this.ConnectionClosed(); } return(IsSave); }
private SqlCommand ProcedureFunction(FinishedProductProvider provider) { SqlCommand command = new SqlCommand(); this.ConnectionOpen(); command.Connection = Connection; this.BeginTransaction(true); command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.RequisitionSet; command.Parameters.Add("@RequisitionDate", SqlDbType.DateTime).Value = provider.ReceivedDate; command.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = provider.DivisionID; return(command); }
protected void ddlFinishedProduct_SelectedIndexChanged(object sender, EventArgs e) { FinishedProductProvider finishedProductProvider = new FinishedProductProvider(); //string[] batchNo = ddlBatchNo.SelectedItem.ToString().Split(' '); DataTable dt = finishedProductProvider.GetFGWiseBatch(ddlFinishedProduct.SelectedValue.Toint()); ddlBatchNo.DataSource = null; ddlBatchNo.DataBind(); ddlBatchNo.DataSource = dt; ddlBatchNo.DataBind(); ddlBatchNo.Items.Insert(0, new ListItem("----------Select Product----------", "0")); ddlBatchNo.SelectedIndex = 0; }
private FinishedProductProvider SendFPToHOEntity() { FinishedProductProvider entity = null; entity = new FinishedProductProvider { ChallanNo = txtChallanNo.Text, ChallanDate = DateTime.ParseExact(txtChallanDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture), DivisionID = int.Parse(ddlDivision.SelectedValue), EntryUserID = Convert.ToInt16(Session["ID"]), UpdateUserID = Convert.ToInt16(Session["ID"]) }; return(entity); }
protected void btnDeleteSelectedRowLSE_Click(object sender, EventArgs e) { ImageButton btnDelete = sender as ImageButton; GridViewRow selectedRow = (GridViewRow)btnDelete.NamingContainer; HiddenField hfDeleteProdID = (HiddenField)selectedRow.FindControl("hfProductID"); List <FinishedProductProvider> finishedProductDetailProviderList = new List <FinishedProductProvider>(); foreach (GridViewRow row in gvRequisition.Rows) { FinishedProductProvider obj = new FinishedProductProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); Label lblProductCode = (Label)row.FindControl("lblProductCode"); Label lblPackSize = (Label)row.FindControl("lblPackSize"); Label lblBatchNo = (Label)row.FindControl("lblBatchNo"); Label lblUnit = (Label)row.FindControl("lblUnit"); Label lblTradePrice = (Label)row.FindControl("lblTradePrice"); TextBox txtBatchQuantity = (TextBox)row.FindControl("txtBatchQuantity"); Label lblTotalTradePrice = (Label)row.FindControl("lblTotalTradePrice"); if (hfRowProductID.Value != hfDeleteProdID.Value) { obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductCode = lblProductCode.Text; obj.ProductName = lblProductName.Text; obj.BatchQuantity = txtBatchQuantity.Text.ToDecimal(); obj.PackSize = lblPackSize.Text; obj.BatchNo = lblBatchNo.Text; obj.MeasurementUnitName = lblUnit.Text; obj.TradePrice = lblTradePrice.Text.ToDecimal(); obj.TotalTradePrice = lblTotalTradePrice.Text.ToDecimal(); finishedProductDetailProviderList.Add(obj); } } gvRequisition.DataSource = finishedProductDetailProviderList; gvRequisition.DataBind(); if (gvRequisition.Rows.Count == 0) { ddlDivision.Enabled = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //AddBlankRowTogvPurchaseProduct(); btnSave.Enabled = true; txtChallanDate.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now); } else { Page.ClientScript.GetPostBackEventReference(this, String.Empty); String eventTarget = Request["__EVENTTARGET"].IsNullOrEmpty() ? String.Empty : Request["__EVENTTARGET"]; if (Request["__EVENTTARGET"] == "SearchPriceSetup") { var finishedProductProvider = new FinishedProductProvider(); string code = Request["__EVENTARGUMENT"]; DataTable dt = finishedProductProvider.GetByID(code); if (dt.IsNotNull()) { try { for (int k = 0; k < dt.Rows.Count; k++) { txtChallanDate.Text = Convert.ToDateTime(dt.Rows[k]["ChallanDate"]).ToString("dd/MM/yyyy"); txtChallanNo.Text = dt.Rows[k]["ChallanNo"].ToString(); ddlDivision.SelectedValue = dt.Rows[k]["DivisionID"].ToString(); } } catch (Exception ex) { throw (ex); } } gvRequisition.DataSource = dt; gvRequisition.DataBind(); btnSave.Visible = false; btnUpdate.Visible = true; } } Session["Value"] = ddlDivision.SelectedValue; }
protected void btnReceived_Click(object sender, EventArgs e) { mode = "Save"; string permisionMessage = CheckUserAuthentication(mode); //if (ckbOption.SelectedValue != "") //{ // statusMessage = CheckUserAuthentication(ckbOption.SelectedItem.ToString()); //} if (String.IsNullOrEmpty(permisionMessage) && string.IsNullOrEmpty(statusMessage)) { bool msg = false; string message = string.Empty; string transactionNo = string.Empty; try { FinishedProductProvider requisitionProvider = RequisitionInfoEntity(); msg = requisitionProvider.Save(out transactionNo); } catch (Exception ex) { message = ex.Message; } if (msg) { Clear(); txtReferenceNo.Text = transactionNo; this.AlertSuccess(lblMsg, MessageConstants.Saved); } else { MessageHelper.ShowAlertMessage(message); } } else { MessageHelper.ShowAlertMessage(permisionMessage + statusMessage); } }
private FinishedProductProvider RequisitionInfoEntity() { FinishedProductProvider entity = null; entity = new FinishedProductProvider { ReferenceNo = txtReferenceNo.Text, BatchNo = txtBatchNo.Text, TheoriticalYield = txtTheoriticalYield.Text, ActualYield = txtActualYield.Text.ToDecimal(), ActualYieldUnit = ddlActualYieldUnit.SelectedValue, CommercialPack = txtCommPackReceived.Text.ToDecimal(), BatchSize = txtBatchSize.Text, ReceivedDate = DateTime.ParseExact(txtReceivedDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture), MfgDate = DateTime.ParseExact(txtMfgDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture), ExpDate = DateTime.ParseExact(txtExpDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture), DivisionID = int.Parse(ddlDivision.SelectedValue), ProductID = int.Parse(ddlFinishedProduct.SelectedValue), EntryUserID = Convert.ToInt16(Session["ID"]) }; return(entity); }
private List <FinishedProductProvider> SendFPToHODetailEntityList() { List <FinishedProductProvider> finishedProductProviderList = new List <FinishedProductProvider>(); foreach (GridViewRow row in gvRequisition.Rows) { FinishedProductProvider obj = new FinishedProductProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); Label lblPackSize = (Label)row.FindControl("lblPackSize"); Label lblBatchNo = (Label)row.FindControl("lblBatchNo"); Label lblUnit = (Label)row.FindControl("lblUnit"); Label lblTradePrice = (Label)row.FindControl("lblTradePrice"); TextBox txtBatchQuantity = (TextBox)row.FindControl("txtBatchQuantity"); Label lblTotalTradePrice = (Label)row.FindControl("lblTotalTradePrice"); obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductName = lblProductName.Text.ToString(); obj.BatchQuantity = txtBatchQuantity.Text.ToDecimal(); obj.PackSize = lblPackSize.Text; obj.BatchNo = lblBatchNo.Text; obj.MeasurementUnitName = lblUnit.Text.ToString(); obj.TradePrice = lblTradePrice.Text.ToDecimal(); obj.TotalTradePrice = lblTotalTradePrice.Text.ToDecimal(); if (txtBatchQuantity.Text.ToDecimal() <= 0) { throw new Exception("Enter Quantity!"); } finishedProductProviderList.Add(obj); } return(finishedProductProviderList); }
public bool Save(FinishedProductProvider FinishedProductProvider, out string transactionNo) { bool IsSave = false; try { SqlCommand command = new SqlCommand(); this.ConnectionOpen(); command.Connection = Connection; this.BeginTransaction(true); command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.FinishedProductSet; SqlParameter tranNo = new SqlParameter("@TransactionNo", SqlDbType.VarChar); tranNo.Direction = ParameterDirection.Output; tranNo.Size = 16; command.Parameters.Add(tranNo); command.Parameters.Add("@ReceivedDate", SqlDbType.DateTime).Value = FinishedProductProvider.ReceivedDate; command.Parameters.Add("@MfgDate", SqlDbType.DateTime).Value = FinishedProductProvider.MfgDate; command.Parameters.Add("@ExpiryDate", SqlDbType.DateTime).Value = FinishedProductProvider.ExpDate; command.Parameters.Add("@FinishedProductID", SqlDbType.VarChar).Value = FinishedProductProvider.ProductID; command.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = FinishedProductProvider.DivisionID; command.Parameters.Add("@BatchNo", SqlDbType.VarChar).Value = FinishedProductProvider.BatchNo; command.Parameters.Add("@BatchSize", SqlDbType.VarChar).Value = FinishedProductProvider.BatchSize; command.Parameters.Add("@TheoriticalYield", SqlDbType.VarChar).Value = FinishedProductProvider.TheoriticalYield; command.Parameters.Add("@CommercialPackRec", SqlDbType.Decimal).Value = FinishedProductProvider.CommercialPack; command.Parameters.Add("@ActualYield", SqlDbType.Decimal).Value = FinishedProductProvider.ActualYield; command.Parameters.Add("@ActualYieldUnit", SqlDbType.VarChar).Value = FinishedProductProvider.ActualYieldUnit; command.Parameters.Add("@EntryUserID", SqlDbType.Int).Value = FinishedProductProvider.EntryUserID; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; command.ExecuteNonQuery(); transactionNo = (string)command.Parameters["@TransactionNo"].Value; command = new SqlCommand(); command.Connection = Connection; command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.ProductStockSet; SqlParameter id1 = new SqlParameter("@ID", SqlDbType.Int); id1.Direction = ParameterDirection.Output; command.Parameters.Add(id1); command.Parameters.Add("@TransactionNo", SqlDbType.VarChar, 16).Value = transactionNo; command.Parameters.Add("@TransactionTypeID", SqlDbType.Int).Value = 2; //// think later about this. command.Parameters.Add("@EntryUserID", SqlDbType.Int).Value = FinishedProductProvider.EntryUserID; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; command.ExecuteNonQuery(); int ProStockID = (int)command.Parameters["@ID"].Value; command = new SqlCommand(); command.Connection = Connection; command.Transaction = this.Transaction; command.CommandText = "DELETE FROM Inventory.ProductCurrentStockDetail WHERE ProdStockID = " + ProStockID + " "; command.ExecuteNonQuery(); command = new SqlCommand(); command.Connection = Connection; command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.ProductStockDetailSet; command.Parameters.Add("@ProStockID", SqlDbType.Int).Value = ProStockID; command.Parameters.Add("@ProductID", SqlDbType.Int).Value = FinishedProductProvider.ProductID; command.Parameters.Add("@ReceivedQuantity", SqlDbType.Decimal).Value = FinishedProductProvider.CommercialPack; command.Parameters.Add("@SentQuantity", SqlDbType.Decimal).Value = 0; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; command.ExecuteNonQuery(); //int RequisitionID = (int)command.Parameters["@ID"].Value; //foreach (ProductionRequisitionDetailProvider RequisitionDetailsProvider in ProductionRequisitionDetailProviderList) //{ // command = new SqlCommand(); // command.Connection = Connection; // command.Transaction = this.Transaction; // command.CommandType = CommandType.StoredProcedure; // command.CommandText = StoredProcedureNames.ProductionRequisitionDetailSet; // command.Parameters.Add("@RequisitionID", SqlDbType.Int).Value = RequisitionID; // command.Parameters.Add("@ProductID", SqlDbType.Int).Value = RequisitionDetailsProvider.ProductID; // command.Parameters.Add("@RequiredQuantity", SqlDbType.Decimal).Value = RequisitionDetailsProvider.RequiredQuantity; // command.Parameters.Add("@SentQuantity", SqlDbType.Decimal).Value = RequisitionDetailsProvider.SentQuantity; // command.Parameters.Add("@Remarks", SqlDbType.VarChar).Value = RequisitionDetailsProvider.Remarks; // command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert; // command.ExecuteNonQuery(); //} this.CommitTransaction(); this.ConnectionClosed(); IsSave = true; } catch (Exception exp) { this.RollbackTransaction(); throw new Exception(exp.Message); } finally { this.ConnectionClosed(); } return(IsSave); }
protected void btnAdd_OnClick(object sender, EventArgs e) { this.AlertNone(lblMsg); ProductProvider productProvider = new ProductProvider(); string measurementUnit = productProvider.GetMeasurementUnit(ddlFinishedProduct.SelectedValue.Toint()); string packSize = productProvider.GetPackSizeName(ddlFinishedProduct.SelectedValue.Toint()); string code = productProvider.GetFinishedProductCode(ddlFinishedProduct.SelectedValue.Toint()); decimal tradePrice = productProvider.GetTradePrice(ddlFinishedProduct.SelectedValue.Toint()); if (ddlFinishedProduct.SelectedValue == "") { MessageHelper.ShowAlertMessage("Select Product!"); lblMsg.Focus(); return; } List <FinishedProductProvider> purchaseLedgerDetailsProviderList = new List <FinishedProductProvider>(); foreach (GridViewRow row in gvRequisition.Rows) { FinishedProductProvider obj = new FinishedProductProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); Label lblPackSize = (Label)row.FindControl("lblPackSize"); Label lblBatchNo = (Label)row.FindControl("lblBatchNo"); Label lblUnit = (Label)row.FindControl("lblUnit"); Label lblTradePrice = (Label)row.FindControl("lblTradePrice"); TextBox txtBatchQuantity = (TextBox)row.FindControl("txtBatchQuantity"); Label lblTotalTradePrice = (Label)row.FindControl("lblTotalTradePrice"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); if (hfRowProductID.Value == ddlFinishedProduct.SelectedValue) { MessageHelper.ShowAlertMessage("This product already exists!"); return; } if (txtBatchQuantity.Text.ToDecimal() <= 0) { MessageHelper.ShowAlertMessage("Enter Quantity!"); return; } obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductName = lblProductName.Text.ToString(); obj.BatchQuantity = txtBatchQuantity.Text.ToDecimal(); obj.PackSize = lblPackSize.Text; obj.BatchNo = lblBatchNo.Text; obj.MeasurementUnitName = lblUnit.Text.ToString(); obj.TradePrice = lblTradePrice.Text.ToDecimal(); obj.TotalTradePrice = lblTotalTradePrice.Text.ToDecimal(); purchaseLedgerDetailsProviderList.Add(obj); } string productName = ddlFinishedProduct.SelectedItem.Text; int productID = ddlFinishedProduct.SelectedValue.Toint(); FinishedProductProvider obj2 = new FinishedProductProvider(); DataTable dt = obj2.GetBatchWiseMFCExpDate(ddlBatchNo.SelectedItem.ToString()); obj2.ProductID = productID; obj2.ProductName = productName; obj2.ProductCode = code; obj2.MeasurementUnitName = measurementUnit; obj2.PackSize = packSize; obj2.TradePrice = tradePrice; obj2.BatchNo = ddlBatchNo.SelectedItem.ToString(); obj2.MfgDate = DateTime.ParseExact(dt.Rows[0]["MfgDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); obj2.MfgDate = DateTime.ParseExact(dt.Rows[0]["ExpDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); purchaseLedgerDetailsProviderList.Add(obj2); if (!divGridForLSE.Visible) { divGridForLSE.Visible = true; } gvRequisition.DataSource = purchaseLedgerDetailsProviderList; gvRequisition.DataBind(); ddlDivision.Enabled = false; }