private void PopulateSize() { try { List<Size> lstSize = new SizeBLL().GetSize(0); chkSize.DataSource = lstSize; chkSize.DataValueField = "SizeID"; chkSize.DataTextField = "SizeName"; chkSize.DataBind(); } catch (Exception ex) { throw ex; } }
protected void gvSize_RowCommand(object sender, GridViewCommandEventArgs e) { try { int SizeID = 0; string SizeName = string.Empty; string SizeBarCode = string.Empty; if (e.CommandName.Equals("Add")) { int retVal = 0; TextBox txtControl; txtControl = ((TextBox)gvSize.FooterRow.FindControl("txtSizeName")); if (txtControl.Text != null) { SizeName = txtControl.Text.Trim(); } txtControl = ((TextBox)gvSize.FooterRow.FindControl("txtSizeBarCode")); if (txtControl.Text != null) { SizeBarCode = txtControl.Text.Trim(); } int mintReturn = new BLL.Component.SizeBLL().InsertSize(SizeName,SizeBarCode); if (mintReturn == -1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Size with same name already exists');", true); } else { // ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Size created successfully');", true); BindSizeMasterGrid(); } } if (e.CommandName.Equals("AddEmpty")) { int retVal = 0; TextBox txtControl; GridViewRow emptyRow = gvSize.Controls[0].Controls[0] as GridViewRow; txtControl = (TextBox)emptyRow.FindControl("txtSizeName1"); if (txtControl.Text != null) { SizeName = txtControl.Text.Trim(); } txtControl = (TextBox)emptyRow.FindControl("txtSizeBarCode1"); if (txtControl.Text != null) { SizeBarCode = txtControl.Text.Trim(); } int mintReturn = new BLL.Component.SizeBLL().InsertSize(SizeName, SizeBarCode); if (mintReturn == -1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Size with same name already exists');", true); } else { // ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Size created successfully');", true); BindSizeMasterGrid(); } } } catch (Exception ex) { } }
private void BindSizeMasterGrid() { List<Size> lstSize = new SizeBLL().GetSize(0); gvSize.DataSource = lstSize; gvSize.DataBind(); }
protected void gvSize_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int SizeID = 0; string SizeName = string.Empty; string SizeBarCode = string.Empty; TextBox txtControl; txtControl = ((TextBox)gvSize.Rows[e.RowIndex].FindControl("txtSizeIDE")); if (txtControl.Text != null) { SizeID = Convert.ToInt32(txtControl.Text.Trim()); } txtControl = ((TextBox)gvSize.Rows[e.RowIndex].FindControl("txtSizeNameE")); if (txtControl != null) { SizeName = txtControl.Text.Trim(); } txtControl = ((TextBox)gvSize.Rows[e.RowIndex].FindControl("txtSizeBarCodeE")); if (txtControl != null) { SizeBarCode = txtControl.Text.Trim(); } int mintReturn = new BLL.Component.SizeBLL().UpdateSize(SizeID, SizeName, SizeBarCode); if (mintReturn == -1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Size with same name already exists');", true); } } catch (Exception ex) { } // ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Updated successfully');", true); gvSize.EditIndex = -1; BindSizeMasterGrid(); }
protected void gvSize_RowDeleting(object sender, GridViewDeleteEventArgs e) { int SizeID = Convert.ToInt32(gvSize.DataKeys[e.RowIndex].Values[0].ToString()); int mintReturn = new BLL.Component.SizeBLL().DeleteSize(SizeID); if (mintReturn == -1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Cannot delete as it is associated with a Product');", true); } BindSizeMasterGrid(); }
private void PopulateData() { int intProductID =0; int.TryParse(Productid.Value, out intProductID); if (intProductID > 0) { bool blnIsProductAdded = false; if (Session["PurchasedProduct"] != null) gobjProduct = (List<PurchasedProduct>)Session["PurchasedProduct"]; for (int i = 0; i < gobjProduct.Count; i++) { if (gobjProduct[i].ProductID == intProductID) { blnIsProductAdded = true; break; } } if (!blnIsProductAdded) { Product objProduct = new ProductBLL().GetProductByID(intProductID); htnProductID.Value = intProductID.ToString(); lblProduct.Text = objProduct.ProductName; lblBarCode.Text = objProduct.BarCode; txtBuyingPrice.Text = objProduct.BuyingPrice.ToString(); txtTax.Text = objProduct.Tax.ToString(); txtMargin.Text = objProduct.Margin.ToString(); txtSellingPrice.Text = objProduct.SellingPrice.ToString(); List<Size> lstSize = new SizeBLL().GetSize(0); string[] arrSizeIDs = objProduct.SizeID.Split(','); List<Size> lstSizeIDs = new List<Size>(); System.Web.UI.HtmlControls.HtmlGenericControl containerDiv; System.Web.UI.HtmlControls.HtmlGenericControl textBoxDiv; System.Web.UI.HtmlControls.HtmlGenericControl mainDiv; int pos = 1; for (int i = 0; i < arrSizeIDs.Length; i++) { for (int j = 0; j < lstSize.Count; j++) { if (arrSizeIDs[i] == lstSize[j].SizeID.ToString()) { mainDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); switch (pos) { case 1: mainDiv.Attributes.Add("style", "float:left"); break; case 2: mainDiv.Attributes.Add("style", "float:left; padding-left:30px"); break; case 3: mainDiv.Attributes.Add("style", "float:right"); break; } pos++; pos = pos > 3 ? 1 : pos; containerDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); containerDiv.Controls.Add(CreateLabel(lstSize[j].SizeID, lstSize[j].SizeName)); mainDiv.Controls.Add(containerDiv); textBoxDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); textBoxDiv.Controls.Add(CreateTextBox(lstSize[j].SizeID, 0)); mainDiv.Controls.Add(textBoxDiv); plhQty.Controls.Add(mainDiv); lstSizeIDs.Add(lstSize[j]); break; } } } Session["ProductSizeIDs"] = lstSizeIDs; lblError.InnerHtml = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "AddEditPurchase", "ShowModalDiv('ModalWindow1','dvInnerWindow',0);", true); } else { lblError.InnerHtml = "Product already added"; } } else { lblError.InnerHtml = "Invalid entry"; } }