public bool Update(ProductionRequisitionDetailProvider provider) { bool IsUpdate = false; try { SqlCommand command = null; command = ProcedureFunction(provider); command.Parameters.Add("@ID", SqlDbType.Int).Value = provider.ID; command.Parameters.Add("@UpdateUserID", SqlDbType.Int).Value = provider.UpdateUserID; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Update; command.ExecuteNonQuery(); this.CommitTransaction(); this.ConnectionClosed(); IsUpdate = true; } catch (Exception exp) { this.RollbackTransaction(); throw new Exception(exp.Message); } finally { this.ConnectionClosed(); } return(IsUpdate); }
public bool Delete(ProductionRequisitionDetailProvider provider) { bool IsDelete = 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.RequisitionDetailSet; command.Parameters.Add("@ID", SqlDbType.Int).Value = provider.ID; command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Delete; command.ExecuteNonQuery(); this.CommitTransaction(); this.ConnectionClosed(); IsDelete = true; } catch (Exception exp) { this.RollbackTransaction(); throw new Exception(exp.Message); } finally { this.ConnectionClosed(); } return(IsDelete); }
private void RowsIn_gvPurchaseForLSE() { List <ProductionRequisitionDetailProvider> purchaseLedgerDetailsProviderList = new List <ProductionRequisitionDetailProvider>(); foreach (GridViewRow row in gvPurchaseForLSE.Rows) { ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtQuantity = (TextBox)row.FindControl("txtQuantityLSE"); TextBox txtSDAmount = (TextBox)row.FindControl("txtSDAmountLSE"); Label lblSDRate = (Label)row.FindControl("lblSDRate"); TextBox txtVatLeviable = (TextBox)row.FindControl("txtVATLeviableLSE"); Label lblVATRate = (Label)row.FindControl("lblVATRate"); TextBox txtVatAmount = (TextBox)row.FindControl("txtVATAmountLSE"); Label lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); obj.ProductID = hfRowProductID.Value.Toint(); obj.RawProductName = lblProductName.Text.ToString(); obj.RequiredQuantity = txtQuantity.Text.ToDecimal(); purchaseLedgerDetailsProviderList.Add(obj); } gvPurchaseForLSE.DataSource = purchaseLedgerDetailsProviderList; gvPurchaseForLSE.DataBind(); }
private List <ProductionRequisitionDetailProvider> requisitionDetailEntityList() { List <ProductionRequisitionDetailProvider> requisitionDetailProviderList = new List <ProductionRequisitionDetailProvider>(); foreach (GridViewRow row in gvPurchaseForLSE.Rows) { ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); TextBox txtRequiredQuantity = (TextBox)row.FindControl("txtRequiredQuantity"); TextBox txtRemarks = (TextBox)row.FindControl("txtRemarks"); Label lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); //ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtSentQuantity = (TextBox)row.FindControl("txtSentQuantity"); TextBox txtPresentStock = (TextBox)row.FindControl("txtPresentStock"); obj.ProductID = hfRowProductID.Value.Toint(); obj.RequiredQuantity = txtRequiredQuantity.Text.ToDecimal(); obj.SentQuantity = txtSentQuantity.Text.ToDecimal(); obj.PresentStock = txtPresentStock.Text.ToDecimal(); obj.Remarks = txtRemarks.Text.ToString(); //if (obj.PresentStock < obj.SentQuantity) // throw new Exception("You can not send more product(s) than present stock."); if (obj.RequiredQuantity <= 0) { throw new Exception("Please input required quantity"); } requisitionDetailProviderList.Add(obj); } return(requisitionDetailProviderList); }
private SqlCommand ProcedureFunction(ProductionRequisitionDetailProvider provider) { SqlCommand command = new SqlCommand(); this.ConnectionOpen(); command.Connection = Connection; this.BeginTransaction(true); command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.RequisitionDetailSet; command.Parameters.Add("@ProductID", SqlDbType.Int).Value = provider.ProductID; command.Parameters.Add("@Rate", SqlDbType.VarChar).Value = provider.RawProductName; command.Parameters.Add("@RateInDollar", SqlDbType.Decimal).Value = provider.RequiredQuantity; command.Parameters.Add("@CurrencyRate", SqlDbType.Decimal).Value = provider.SentQuantity; command.Parameters.Add("@CurrencyRate", SqlDbType.VarChar).Value = provider.Remarks; return(command); }
protected void btnAddRow_Click(object sender, EventArgs e) { this.AlertNone(lblMsg); AjaxControlToolkit.ComboBox ddlProductValidation = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct"); if (ddlProductValidation.SelectedValue == "") { MessageHelper.ShowAlertMessage("Select Product!"); return; } string productName = ddlProductValidation.SelectedItem.Text; int productID = ddlProductValidation.SelectedValue.Toint(); List <ProductionRequisitionDetailProvider> providerList = new List <ProductionRequisitionDetailProvider>(); #region new list ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); providerList.Add(obj); #endregion }
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 <ProductionRequisitionDetailProvider> purchaseLedgerDetailsProviderList = new List <ProductionRequisitionDetailProvider>(); foreach (GridViewRow row in gvPurchaseForLSE.Rows) { ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtRequiredQuantity = (TextBox)row.FindControl("txtRequiredQuantity"); TextBox txtUnit = (TextBox)row.FindControl("txtUnit"); Label lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); TextBox txtSentQuantity = (TextBox)row.FindControl("txtSentQuantity"); TextBox txtPresentStock = (TextBox)row.FindControl("txtPresentStock"); TextBox txtRemarks = (TextBox)row.FindControl("txtRemarks"); if (hfRowProductID.Value != hfDeleteProdID.Value) { obj.ProductID = hfRowProductID.Value.Toint(); obj.RawProductName = lblProductName.Text.ToString(); obj.RequiredQuantity = txtRequiredQuantity.Text.ToDecimal(); obj.MeasurementUnitName = txtUnit.Text; obj.SentQuantity = txtSentQuantity.Text.ToDecimal(); obj.PresentStock = txtPresentStock.Text.ToDecimal(); obj.Remarks = txtRemarks.Text.ToString(); purchaseLedgerDetailsProviderList.Add(obj); } } gvPurchaseForLSE.DataSource = purchaseLedgerDetailsProviderList; gvPurchaseForLSE.DataBind(); if (gvPurchaseForLSE.Rows.Count == 0) { ddlRequisitionDivision.Enabled = true; } }
protected void btnAdd_OnClick(object sender, EventArgs e) { this.AlertNone(lblMsg); ProductProvider productProvider = new ProductProvider(); AjaxControlToolkit.ComboBox ddlProductValidation = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct"); if (ddlProductValidation.SelectedValue == "") { MessageHelper.ShowAlertMessage("Select Product!"); lblMsg.Focus(); return; } string measurementUnit = productProvider.GetMeasurementUnit(ddlProductValidation.SelectedValue.Toint()); List <ProductionRequisitionDetailProvider> purchaseLedgerDetailsProviderList = new List <ProductionRequisitionDetailProvider>(); foreach (GridViewRow row in gvPurchaseForLSE.Rows) { ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtRequiredQuantity = (TextBox)row.FindControl("txtRequiredQuantity"); TextBox txtUnit = (TextBox)row.FindControl("txtUnit"); TextBox txtSentQuantity = (TextBox)row.FindControl("txtSentQuantity"); TextBox txtPresentStock = (TextBox)row.FindControl("txtPresentStock"); TextBox txtRemarks = (TextBox)row.FindControl("txtRemarks"); Label lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); if (hfRowProductID.Value == ddlProductValidation.SelectedValue) { MessageHelper.ShowAlertMessage("This product already added!"); return; } if (txtRequiredQuantity.Text.ToDecimal() <= 0) { MessageHelper.ShowAlertMessage("Enter Quantity!"); return; } obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductName = lblProductName.Text.ToString(); obj.PresentStock = txtPresentStock.Text.ToDecimal(); obj.MeasurementUnitName = txtUnit.Text.ToString(); obj.RequiredQuantity = txtRequiredQuantity.Text.ToDecimal(); obj.SentQuantity = txtSentQuantity.Text.ToDecimal(); obj.Remarks = txtRemarks.Text.ToString(); purchaseLedgerDetailsProviderList.Add(obj); } AjaxControlToolkit.ComboBox ddlProduct = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct"); string productName = ddlProduct.SelectedItem.Text; int productID = ddlProduct.SelectedValue.Toint(); ProductionRequisitionDetailProvider obj2 = new ProductionRequisitionDetailProvider(); obj2.ProductID = productID; obj2.ProductName = productName; obj2.MeasurementUnitName = measurementUnit; obj2.PresentStock = productProvider.GetPresentStock(obj2.ProductID); purchaseLedgerDetailsProviderList.Add(obj2); if (!divGridForLSE.Visible) { divGridForLSE.Visible = true; } gvPurchaseForLSE.DataSource = purchaseLedgerDetailsProviderList; gvPurchaseForLSE.DataBind(); }
protected void btnSave_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 { ProductionRequisitionProvider requisitionProvider = new ProductionRequisitionProvider(); requisitionProvider.TransactionNo = txtRefNo.Text; requisitionProvider.BatchNo = txtBatchNo.Text; requisitionProvider.RetRejDate = DateTime.ParseExact(txtRetRejDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); requisitionProvider.StatusID = ckbOption.SelectedValue.Toint(); requisitionProvider.IsBatchRejcted = ckbBatchRejection.Checked; requisitionProvider.EntryUserID = Convert.ToInt16(Session["ID"]); List <ProductionRequisitionDetailProvider> requisitionDetailProviderList = new List <ProductionRequisitionDetailProvider>(); foreach (GridViewRow row in gvPurchaseForLSE.Rows) { ProductionRequisitionDetailProvider obj = new ProductionRequisitionDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); TextBox txtReturnQuantity = (TextBox)row.FindControl("txtReturnQuantity"); TextBox txtRejectQuantity = (TextBox)row.FindControl("txtRejectQuantity"); TextBox txtReturnReceived = (TextBox)row.FindControl("txtReturnReceived"); TextBox txtRejectReceived = (TextBox)row.FindControl("txtRejectReceived"); TextBox txtRemarks = (TextBox)row.FindControl("txtRemarks"); //Label lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); Label lblProductName = (Label)row.FindControl("lblProduct"); obj.ProductID = hfRowProductID.Value.Toint(); if (txtReturnQuantity.Text.ToDecimal() > 0 || txtRejectQuantity.Text.ToDecimal() > 0 || txtReturnReceived.Text.ToDecimal() > 0 || txtRejectReceived.Text.ToDecimal() > 0) { obj.ReturnQuantity = txtReturnQuantity.Text.ToDecimal(); // obj.RejectQuantity = txtRejectQuantity.Text.ToDecimal(); // obj.ReturnReceived = txtReturnReceived.Text.ToDecimal(); // obj.RejectReceived = txtRejectReceived.Text.ToDecimal(); // //if (obj.ReturnQuantity <= 0 || obj.RejectQuantity <= 0) // throw new Exception("Please input return or reject quantity"); obj.Remarks = txtRemarks.Text.ToString(); requisitionDetailProviderList.Add(obj); } } if ((requisitionDetailProviderList == null) || (requisitionDetailProviderList.Count == 0)) { MessageHelper.ShowAlertMessage("Please put values for quantity"); return; } msg = requisitionProvider.Return(requisitionDetailProviderList); } catch (Exception ex) { message = ex.Message; } if (msg) { Clear(); this.AlertSuccess(lblMsg, MessageConstants.Saved); } else { MessageHelper.ShowAlertMessage(message); } } else { MessageHelper.ShowAlertMessage(permisionMessage + statusMessage); } }