protected void txtUnitPrice_TextChanged(object sender, EventArgs e) { try { if (sender != null) { TextBox txtUnitPrice = (TextBox)sender; GridViewRow gvRow = (GridViewRow)txtUnitPrice.NamingContainer; List <ATTInvPurchaseOrderDetail> lstPoDetail = new List <ATTInvPurchaseOrderDetail>(); if (Session["PoDetail"] != null) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoDetail"]; ATTInvPurchaseOrderDetail objPo = lstPoDetail.Find(delegate(ATTInvPurchaseOrderDetail obj) { return(obj.ItemsCategoryID == int.Parse(gvRow.Cells[1].Text) && obj.ItemsSubCategoryID == int.Parse(gvRow.Cells[2].Text) && obj.ItemsID == int.Parse(gvRow.Cells[3].Text)); } ); objPo.UnitPrice = double.Parse(txtUnitPrice.Text); } } foreach (GridViewRow row in grdPurchaseOrder.Rows) { TextBox txtPrice = (TextBox)row.FindControl("txtUnitPrice"); row.Cells[4].Text = txtPrice.Text; double totalPrice = double.Parse(txtPrice.Text) * double.Parse(row.Cells[9].Text); row.Cells[10].Text = totalPrice.ToString(); } } catch (Exception ex) { throw(ex); } }
public static List <ATTInvPurchaseOrderDetail> GetPurchaseOrderDetail(string orderNo) { try { List <ATTInvPurchaseOrderDetail> lst = new List <ATTInvPurchaseOrderDetail>(); DataTable tbl = new DataTable(); tbl = DLLInvPurchaseOrderDetail.GetPurchaseOrderDetail(orderNo); foreach (DataRow row in tbl.Rows) { ATTInvPurchaseOrderDetail obj = new ATTInvPurchaseOrderDetail(); obj.ItemsCategoryID = int.Parse(row["ITEMS_CATEGORY_ID"].ToString()); obj.ItemsCategoryName = row["ITEMS_CATEGORY_NAME"].ToString(); obj.ItemsSubCategoryID = int.Parse(row["ITEMS_SUB_CATEGORY_ID"].ToString()); obj.ItemsSubCategoryName = row["ITEMS_SUB_CATEGORY_NAME"].ToString(); obj.ItemsID = int.Parse(row["ITEMS_ID"].ToString()); obj.ItemsName = row["ITEMS_NAME"].ToString(); obj.SeqNo = int.Parse(row["SEQ_NO"].ToString()); obj.ManuCompany = row["manu_company"].ToString(); obj.ManuDate = row["manu_date"].ToString(); obj.Brand = row["brand"].ToString(); obj.UnitPrice = double.Parse(row["UNIT_PRICE"].ToString()); obj.TotalQty = int.Parse(row["TOTAL_QUANTITY"].ToString()); obj.Specification = ""; obj.Action = "N"; lst.Add(obj); } return(lst); } catch (Exception ex) { throw (ex); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { double price = 0.0; bool flag = false; List <ATTInvOrgItemsPrice> lstItems = new List <ATTInvOrgItemsPrice>(); lstItems = (List <ATTInvOrgItemsPrice>)Session["PoItems"]; if (ddlItems_cat.SelectedIndex > 0 && lstItems.Count > 0) { price = lstItems[ddlItems_cat.SelectedIndex - 1].UnitPrice; } List <ATTInvPurchaseOrderDetail> lstPoDetail = new List <ATTInvPurchaseOrderDetail>(); if (Session["PoDetail"] != null) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoDetail"]; if (grdPurchaseOrder.SelectedIndex > -1) { GridViewRow gvRow = grdPurchaseOrder.SelectedRow; // double i = double.Parse(gvRow.Cells[4].Text); ATTInvPurchaseOrderDetail objPoD = lstPoDetail.Find(delegate(ATTInvPurchaseOrderDetail objPd) { return((objPd.ItemsCategoryID == int.Parse(gvRow.Cells[1].Text)) && (objPd.ItemsSubCategoryID == int.Parse(gvRow.Cells[2].Text)) && (objPd.ItemsID == int.Parse(gvRow.Cells[3].Text))); } ); if (objPoD != null) { objPoD.TotalQty = int.Parse(txtQty_cat.Text); objPoD.ManuCompany = txtManuCom.Text; objPoD.ManuDate = txtManuDate.Text; //objPoD.Specification = txtManuSpec.Text; objPoD.Brand = txtBrand.Text; ClearAddControls(); ddlCategory_cat.SelectedIndex = -1; ddlSubCategory_cat.SelectedIndex = -1; grdPurchaseOrder.SelectedIndex = -1; grdPurchaseOrder.DataSource = lstPoDetail; grdPurchaseOrder.DataBind(); Session["PoDetail"] = lstPoDetail; flag = true; } } else { flag = lstPoDetail.Exists(delegate(ATTInvPurchaseOrderDetail objPd) { return((objPd.ItemsCategoryID == int.Parse(ddlCategory_cat.SelectedValue)) && (objPd.ItemsSubCategoryID == int.Parse(ddlSubCategory_cat.SelectedValue)) && (objPd.ItemsID == int.Parse(ddlItems_cat.SelectedValue))); } ); if (flag) { this.lblStatusMessageTitle.Text = "खरिद अर्डर "; this.lblStatusMessage.Text = " यो सामान पहिले नै खरिदको निमित्त राख्नु भइसक्यो । कृपया अर्को सामान छान्नुहोस्।"; this.programmaticModalPopup.Show(); } } } if (!flag) { lstPoDetail.Add(new ATTInvPurchaseOrderDetail(int.Parse(ddlCategory_cat.SelectedValue), ddlCategory_cat.SelectedItem.ToString(), int.Parse(ddlSubCategory_cat.SelectedValue), ddlSubCategory_cat.SelectedItem.ToString(), int.Parse(ddlItems_cat.SelectedValue), ddlItems_cat.SelectedItem.ToString(), price, int.Parse(txtQty_cat.Text), txtManuCom.Text, txtManuDate.Text, txtBrand.Text, "A")); ClearAddControls(); grdPurchaseOrder.DataSource = lstPoDetail; grdPurchaseOrder.DataBind(); Session["PoDetail"] = lstPoDetail; } btnSubmit.Enabled = true; } catch (Exception ex) { this.lblStatusMessageTitle.Text = "Error Status"; this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
protected void grdPurchaseOrderDetail_RowDeleting(object sender, GridViewDeleteEventArgs e) { int?type = null; type = int.Parse(hdnType.Value); if (type != null) { List <ATTInvPurchaseOrderDetail> lstPoDetail = new List <ATTInvPurchaseOrderDetail>(); if (type == 0) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoUpdDetail"]; } else if (type == 1) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoRecmUpdDetail"]; } else if (type == 2) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoApprvUpdDetail"]; } GridViewRow gvRow = grdPurchaseOrderDetail.Rows[e.RowIndex]; string action = gvRow.Cells[13].Text; LinkButton lnkBtn = (LinkButton)gvRow.Cells[12].Controls[0]; if (action == "A") { lstPoDetail.RemoveAt(e.RowIndex); grdPurchaseOrderDetail.DataSource = lstPoDetail; grdPurchaseOrderDetail.DataBind(); } else { ATTInvPurchaseOrderDetail objPoD = lstPoDetail.Find(delegate(ATTInvPurchaseOrderDetail objPd) { return((objPd.ItemsCategoryID == int.Parse(gvRow.Cells[1].Text)) && (objPd.ItemsSubCategoryID == int.Parse(gvRow.Cells[2].Text)) && (objPd.ItemsID == int.Parse(gvRow.Cells[3].Text))); } ); if (action == "N" || action == "E") { lnkBtn.Text = "Undo"; gvRow.Cells[13].Text = "D"; gvRow.ForeColor = System.Drawing.Color.Red; } else if (action == "D") { lnkBtn.Text = "Remove"; gvRow.Cells[13].Text = "E"; gvRow.ForeColor = System.Drawing.Color.Black; } if (objPoD != null) { if ((lnkBtn.Text == "Undo") && (gvRow.Cells[13].Text == "D")) { objPoD.Action = "D"; } else if ((lnkBtn.Text == "Remove") && (gvRow.Cells[13].Text == "E")) { objPoD.Action = "E"; } } } } }
protected void txtUnitPrice_TextChanged(object sender, EventArgs e) { try { if (type == 0) { if (sender != null) { TextBox txtUnitPrice = (TextBox)sender; GridViewRow gvRow = (GridViewRow)txtUnitPrice.NamingContainer; List <ATTInvPurchaseOrderDetail> lstPoDetail = new List <ATTInvPurchaseOrderDetail>(); if (type != null) { if (type == 0) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoUpdDetail"]; } else if (type == 1) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoRecmUpdDetail"]; } else if (type == 2) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoApprvUpdDetail"]; } ATTInvPurchaseOrderDetail objPo = lstPoDetail.Find(delegate(ATTInvPurchaseOrderDetail obj) { return(obj.ItemsCategoryID == int.Parse(gvRow.Cells[1].Text) && obj.ItemsSubCategoryID == int.Parse(gvRow.Cells[2].Text) && obj.ItemsID == int.Parse(gvRow.Cells[3].Text)); } ); objPo.UnitPrice = double.Parse(txtUnitPrice.Text); if (objPo.Action == "A") { objPo.Action = "A"; } else { objPo.Action = "E"; } } } foreach (GridViewRow row in grdPurchaseOrderDetail.Rows) { TextBox txtPrice = (TextBox)row.FindControl("txtUnitPrice"); row.Cells[4].Text = txtPrice.Text; double totalPrice = double.Parse(txtPrice.Text) * double.Parse(row.Cells[9].Text); row.Cells[10].Text = totalPrice.ToString(); } } } catch (Exception ex) { this.lblStatusMessageTitle.Text = "Error Status"; this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { //int? type = null; //type = int.Parse(hdnType.Value); double price = 0.0; bool flag = false; List <ATTInvOrgItemsPrice> lstItems = new List <ATTInvOrgItemsPrice>(); lstItems = (List <ATTInvOrgItemsPrice>)Session["PoDetItems"]; if (ddlItems_cat.SelectedIndex > 0 && lstItems.Count > 0) { price = lstItems[ddlItems_cat.SelectedIndex - 1].UnitPrice; } List <ATTInvPurchaseOrderDetail> lstPoDetail = new List <ATTInvPurchaseOrderDetail>(); if (type != null) { // if (type == 0) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoUpdDetail"]; } else if (type == 1) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoRecmUpdDetail"]; } else if (type == 2) { lstPoDetail = (List <ATTInvPurchaseOrderDetail>)Session["PoApprvUpdDetail"]; } if (grdPurchaseOrderDetail.SelectedIndex > -1) { GridViewRow gvRow = grdPurchaseOrderDetail.SelectedRow; //int i = int.Parse(gvRow.Cells[4].Text); ATTInvPurchaseOrderDetail objPoD = lstPoDetail.Find(delegate(ATTInvPurchaseOrderDetail objPd) { return((objPd.ItemsCategoryID == int.Parse(gvRow.Cells[1].Text)) && (objPd.ItemsSubCategoryID == int.Parse(gvRow.Cells[2].Text)) && (objPd.ItemsID == int.Parse(gvRow.Cells[3].Text))); } ); if (objPoD != null) { objPoD.TotalQty = int.Parse(txtQty_cat.Text); if (objPoD.Action == "N" || objPoD.Action == "E") { objPoD.Action = "E"; } else { objPoD.Action = "A"; } ClearAddControls(); ddlCategory_cat.SelectedIndex = -1; ddlSubCategory_cat.SelectedIndex = -1; grdPurchaseOrderDetail.SelectedIndex = -1; grdPurchaseOrderDetail.DataSource = lstPoDetail; grdPurchaseOrderDetail.DataBind(); if (type == 0) { Session["PoUpdDetail"] = lstPoDetail; } else if (type == 1) { Session["PoRecmUpdDetail"] = lstPoDetail; } else if (type == 2) { Session["PoApprvUpdDetail"] = lstPoDetail; } flag = true; } } else { flag = lstPoDetail.Exists(delegate(ATTInvPurchaseOrderDetail objPd) { return((objPd.ItemsCategoryID == int.Parse(ddlCategory_cat.SelectedValue)) && (objPd.ItemsSubCategoryID == int.Parse(ddlSubCategory_cat.SelectedValue)) && (objPd.ItemsID == int.Parse(ddlItems_cat.SelectedValue))); } ); if (flag) { this.lblStatusMessageTitle.Text = "खरिद अर्डर "; this.lblStatusMessage.Text = " यो सामान पहिले नै खरिदको निमित्त राख्नु भइसक्यो । कृपया अर्को सामान छान्नुहोस्।"; this.programmaticModalPopup.Show(); } } } if (!flag) { lstPoDetail.Add(new ATTInvPurchaseOrderDetail(int.Parse(ddlCategory_cat.SelectedValue), ddlCategory_cat.SelectedItem.ToString(), int.Parse(ddlSubCategory_cat.SelectedValue), ddlSubCategory_cat.SelectedItem.ToString(), int.Parse(ddlItems_cat.SelectedValue), ddlItems_cat.SelectedItem.ToString(), price, int.Parse(txtQty_cat.Text), "A")); ClearAddControls(); grdPurchaseOrderDetail.DataSource = lstPoDetail; grdPurchaseOrderDetail.DataBind(); if (type == 0) { Session["PoUpdDetail"] = lstPoDetail; } else if (type == 1) { Session["PoRecmUpdDetail"] = lstPoDetail; } else if (type == 2) { Session["PoApprvUpdDetail"] = lstPoDetail; } } btnSubmit.Enabled = true; } catch (Exception ex) { this.lblStatusMessageTitle.Text = "Error Status"; this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }