private List <DeliveryChallanDetailProvider> deliveryDetailEntityList() { List <DeliveryChallanDetailProvider> deliveryDetailsProviderList = new List <DeliveryChallanDetailProvider>(); foreach (GridViewRow row in gvDeliveryChallan.Rows) { DeliveryChallanDetailProvider obj = new DeliveryChallanDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); TextBox txtProvidedQuantity = (TextBox)row.FindControl("txtProvidedQuantity"); TextBox txtSupplierChallanNo = (TextBox)row.FindControl("txtSupplierChallanNo"); DropDownList ddlSupplier = (DropDownList)row.FindControl("ddlSupplier"); DropDownList ddlPurchaseOrderNo = (DropDownList)row.FindControl("ddlPurchaseOrderNo"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtReceivedQuantity = (TextBox)row.FindControl("txtReceivedQuantity"); TextBox txtSupplierChallanDate = (TextBox)row.FindControl("txtSupplierChallanDate"); obj.ProductID = hfRowProductID.Value.Toint(); obj.SupplierID = Convert.ToInt16(ddlSupplier.SelectedValue); string[] PONo = ddlPurchaseOrderNo.SelectedItem.Text.Split('-'); obj.POrderNo = PONo[0].Trim(); obj.ProvidedQuantity = txtProvidedQuantity.Text.ToDecimal(); obj.ReceivedQuantity = txtReceivedQuantity.Text.ToDecimal(); obj.SupplierChallanNo = txtSupplierChallanNo.Text.ToString(); obj.SupplierChallanDate = txtSupplierChallanDate.Text; deliveryDetailsProviderList.Add(obj); } return(deliveryDetailsProviderList); }
public bool Delete(DeliveryChallanDetailProvider 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); }
public bool Update(DeliveryChallanDetailProvider 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); }
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 <DeliveryChallanDetailProvider> deliveryChallanDetailProviderList = new List <DeliveryChallanDetailProvider>(); foreach (GridViewRow row in gvDeliveryChallan.Rows) { DeliveryChallanDetailProvider obj = new DeliveryChallanDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); TextBox txtReceivedQuantity = (TextBox)row.FindControl("txtReceivedQuantity"); DropDownList ddlPurchaseOrderNo = (DropDownList)row.FindControl("ddlPurchaseOrderNo"); //DropDownList ddlReqRefNo = (DropDownList)row.FindControl("ddlReqRefNo"); DropDownList ddlSupplier = (DropDownList)row.FindControl("ddlSupplier"); // TextBox txtValue = (TextBox)row.FindControl("txtValue"); //TextBox txtPurchaseDate = (TextBox)row.FindControl("txtPurchaseDate"); TextBox txtSupplierChallanDate = (TextBox)row.FindControl("txtSupplierChallanDate"); TextBox txtUnit = (TextBox)row.FindControl("txtUnit"); ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE"); TextBox txtProvidedQuantity = (TextBox)row.FindControl("txtProvidedQuantity"); TextBox txtSupplierChallanNo = (TextBox)row.FindControl("txtSupplierChallanNo"); if (hfRowProductID.Value != hfDeleteProdID.Value) { obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductName = lblProductName.Text.ToString(); obj.ProvidedQuantity = txtProvidedQuantity.Text.ToDecimal(); // obj.ReqReferenceNo = ddlReqRefNo.SelectedItem.Value.ToString(); obj.SupplierName = ddlSupplier.SelectedItem.Value.ToString(); obj.POrderNo = ddlPurchaseOrderNo.SelectedItem.Value.ToString(); obj.ReceivedQuantity = txtReceivedQuantity.Text.ToDecimal(); //obj.PurchaseDate = Convert.ToDateTime(txtPurchaseDate.Text).ToString("dd/MM/yyyy"); //obj.PurchaseDate = txtPurchaseDate.Text; obj.SupplierChallanDate = txtSupplierChallanDate.Text; obj.SupplierChallanNo = txtSupplierChallanNo.Text.ToString(); // obj.Value = txtValue.Text.ToDecimal(); obj.MeasurementUnitName = txtUnit.Text; deliveryChallanDetailProviderList.Add(obj); } } gvDeliveryChallan.DataSource = deliveryChallanDetailProviderList; gvDeliveryChallan.DataBind(); }
private SqlCommand ProcedureFunction(DeliveryChallanDetailProvider provider) { SqlCommand command = new SqlCommand(); this.ConnectionOpen(); command.Connection = Connection; this.BeginTransaction(true); command.Transaction = this.Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.DeliveryChallanDetailSet; 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 <DeliveryChallanDetailProvider> providerList = new List <DeliveryChallanDetailProvider>(); DeliveryChallanDetailProvider obj = new DeliveryChallanDetailProvider(); providerList.Add(obj); }
protected void btnAdd_OnClick(object sender, EventArgs e) { this.AlertNone(lblMsg); AjaxControlToolkit.ComboBox ddlProductValidation = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct"); if (ddlProductValidation.SelectedValue == "") { MessageHelper.ShowAlertMessage("Select Product!"); lblMsg.Focus(); return; } ProductProvider productProvider = new ProductProvider(); List <DeliveryChallanDetailProvider> deliveryChallanDetailProviderList = new List <DeliveryChallanDetailProvider>(); foreach (GridViewRow row in gvDeliveryChallan.Rows) { DeliveryChallanDetailProvider obj = new DeliveryChallanDetailProvider(); HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID"); Label lblProductName = (Label)row.FindControl("lblProduct"); DropDownList ddlPurchaseOrderNo = (DropDownList)row.FindControl("ddlPurchaseOrderNo"); DropDownList ddlReqRefNo = (DropDownList)row.FindControl("ddlReqRefNo"); DropDownList ddlSupplier = (DropDownList)row.FindControl("ddlSupplier"); TextBox txtSupplierChallanNo = (TextBox)row.FindControl("txtSupplierChallanNo"); TextBox txtReceivedQuantity = (TextBox)row.FindControl("txtReceivedQuantity"); TextBox txtProvidedQuantity = (TextBox)row.FindControl("txtProvidedQuantity"); TextBox txtSupplierChallanDate = (TextBox)row.FindControl("txtSupplierChallanDate"); TextBox txtUnit = (TextBox)row.FindControl("txtUnit"); 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 (txtProvidedQuantity.Text.ToDecimal() <= 0) { MessageHelper.ShowAlertMessage("Please enter provided quantity!"); return; } obj.ProductID = hfRowProductID.Value.Toint(); obj.ProductName = lblProductName.Text.ToString(); obj.POrderNo = ddlPurchaseOrderNo.SelectedItem.Value; obj.SupplierChallanDate = txtSupplierChallanDate.Text; obj.SupplierName = ddlSupplier.SelectedItem.Value; obj.MeasurementUnitName = txtUnit.Text; obj.ProvidedQuantity = txtProvidedQuantity.Text.ToDecimal(); obj.SupplierChallanNo = txtSupplierChallanNo.Text; obj.ReceivedQuantity = txtReceivedQuantity.Text.ToDecimal(); deliveryChallanDetailProviderList.Add(obj); } AjaxControlToolkit.ComboBox ddlProduct = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct"); string productName = ddlProduct.SelectedItem.Text; int productID = ddlProduct.SelectedValue.Toint(); DeliveryChallanDetailProvider obj2 = new DeliveryChallanDetailProvider(); obj2.ProductID = productID; obj2.ProductName = productName; obj2.MeasurementUnitName = productProvider.GetMeasurementUnit(obj2.ProductID); obj2.PackSizeName = productProvider.GetPackSizeName(obj2.ProductID); deliveryChallanDetailProviderList.Add(obj2); if (!divGridForPO.Visible) { divGridForPO.Visible = true; } int divisionID = ddlProductDivision.SelectedValue.ToInt(); int challanTypeID = ddlChallanType.SelectedValue.ToInt(); HttpContext.Current.ApplicationInstance.Session["DivisionID"] = divisionID; HttpContext.Current.ApplicationInstance.Session["ChallanTypeID"] = challanTypeID; gvDeliveryChallan.DataSource = deliveryChallanDetailProviderList; gvDeliveryChallan.DataBind(); //HttpContext.Current.ApplicationInstance.Session["DivisionID"] = null; }
protected void Page_Load(object sender, EventArgs e) { // string userName = Session["UserName"].ToString(); if (!IsPostBack) { AddBlankRowTogvPurchaseProduct(); btnSave.Enabled = true; txtDeliveryChallanDate.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") { int divisionID = ddlProductDivision.SelectedValue.ToInt(); HttpContext.Current.ApplicationInstance.Session["DivisionID"] = divisionID; int challanTypeID = ddlChallanType.SelectedValue.Toint(); HttpContext.Current.ApplicationInstance.Session["ChallanTypeID"] = challanTypeID; //if (userName == "Nazrul") // gvDeliveryChallan.Columns[8].Visible = true; var deliveryChallanProvider = new DeliveryChallanProvider(); string code = Request["__EVENTARGUMENT"]; DataTable dt = deliveryChallanProvider.GetByID(code); if (dt.IsNotNull()) { PopulateControls(dt); List <DeliveryChallanDetailProvider> deliveryChallanDetailProviderList1 = new List <DeliveryChallanDetailProvider>(); for (int k = 0; k < dt.Rows.Count; k++) { DeliveryChallanDetailProvider obj2 = new DeliveryChallanDetailProvider(); obj2.ProductID = Convert.ToInt16(dt.Rows[k]["ProductID"]); //Explicit type conversion obj2.ProductName = dt.Rows[k]["ProductName"].ToString(); obj2.SupplierChallanDate = dt.Rows[k]["SupplierChallanDate"].ToString(); obj2.SupplierChallanNo = dt.Rows[k]["SupplierChallanNo"].ToString(); obj2.MeasurementUnitName = dt.Rows[k]["MeasurementUnitName"].ToString(); obj2.ProvidedQuantity = Convert.ToDecimal(dt.Rows[k]["ProvidedQuantity"]); obj2.Value = Convert.ToDecimal(dt.Rows[k]["Value"]); obj2.ReceivedQuantity = Convert.ToDecimal(dt.Rows[k]["ReceivedQuantity"]); deliveryChallanDetailProviderList1.Add(obj2); } gvDeliveryChallan.DataSource = deliveryChallanDetailProviderList1; gvDeliveryChallan.DataBind(); //HttpContext.Current.ApplicationInstance.Session["DivisionID"] = null; int nl = 0; foreach (GridViewRow row in gvDeliveryChallan.Rows) { DropDownList ddlSupplier = (DropDownList)row.FindControl("ddlSupplier"); DropDownList ddlPurchaseOrderNo = (DropDownList)row.FindControl("ddlPurchaseOrderNo"); ddlSupplier.SelectedValue = dt.Rows[nl]["SupplierID"].ToString(); ddlPurchaseOrderNo.SelectedValue = dt.Rows[nl]["POrderNo"].ToString(); nl++; } } if (ckbOption.SelectedValue.Toint() == 2) { txtVehicleInfo.Enabled = false; txtDeliveryChallanDate.Enabled = false; //ddlDestinationUnit.Enabled = false; gvDeliveryChallan.Enabled = false; btnAdd.Enabled = false; btnUpdate.Enabled = false; } else { btnUpdate.Enabled = true; } btnSave.Visible = false; btnUpdate.Visible = true; } } }