public void update(string _lblProductId, string _Count) { int remain; int productid = !String.IsNullOrEmpty(_lblProductId) ? Convert.ToInt32(_lblProductId) : 0; //Domain.Item existing = new Domain.Item(); Domain.Item existing = itemrepo.Find(p => p.ProductId == productid).FirstOrDefault(); int value = existing.Count; remain = (value) - (Convert.ToInt32(_Count)); existing.Count = remain; existing.LastUpdatedBy = "admin"; existing.LastUpdationTime = DateTime.Now; itemrepo.Edit(existing); }
protected void gvItemDetails_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblItemID = (Label)gvItemDetails.Rows[e.RowIndex].FindControl("lblItemID"); DropDownList ddlEditProduct = (DropDownList)gvItemDetails.Rows[e.RowIndex].FindControl("ddlEditProduct"); DropDownList ddlEditvendor = (DropDownList)gvItemDetails.Rows[e.RowIndex].FindControl("ddlEditvendor"); TextBox ddlEditBillno = (TextBox)gvItemDetails.Rows[e.RowIndex].FindControl("ddlEditBillno"); TextBox txtEditCount = (TextBox)gvItemDetails.Rows[e.RowIndex].FindControl("txtEditCount"); TextBox txtEditthresh = (TextBox)gvItemDetails.Rows[e.RowIndex].FindControl("txtEditThresh"); if (ddlEditProduct.SelectedItem.Text != ("") && txtEditCount.Text != ("")) { Domain.Item existing = itemRepo.GetById(Convert.ToInt32(lblItemID.Text)); if (existing != null) { existing.ProductId = Convert.ToInt32(ddlEditProduct.SelectedValue); existing.Count = Convert.ToInt32(txtEditCount.Text); existing.TenantId = tenantId; //existing.VendorID = Convert.ToInt32(ddlEditvendor.SelectedValue); //existing.BillNo = ddlEditBillno.Text; //existing.ThreshHold = Convert.ToInt32(txtEditthresh.Text); existing.LastUpdatedBy = "admin"; existing.LastUpdationTime = DateTime.Now; } itemRepo.Edit(existing); itemRepo.Save(); gvItemDetails.EditIndex = -1; //updatingitem(); BindData(); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Stock Sucessfully Updated');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true); } }
protected void gvItemDetails_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("ADD")) { DropDownList ddlAddProduct = (DropDownList)gvItemDetails.FooterRow.FindControl("ddlAddProduct"); int productid = !String.IsNullOrEmpty(ddlAddProduct.Text) ? Convert.ToInt32(ddlAddProduct.Text) : 0; // DropDownList ddlAddvendor = (DropDownList)gvItemDetails.FooterRow.FindControl("ddlAddvendor"); TextBox ddlAddBillno = (TextBox)gvItemDetails.FooterRow.FindControl("ddlAddBillno"); TextBox txtAddCount = (TextBox)gvItemDetails.FooterRow.FindControl("txtAddCount"); TextBox txtAddthresh = (TextBox)gvItemDetails.FooterRow.FindControl("txtAddThresh"); TextBox tbxfrom = (TextBox)gvItemDetails.FooterRow.FindControl("tbxfrom"); DateTime puchasedate = Convert.ToDateTime(tbxfrom.Text); DateTime date = DateTime.Today; if (puchasedate > date) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('PurchaseDate Not be Greter than CurrentDate');", true); } else { Domain.Item existing = itemRepo.Find(p => p.ProductId == productid).FirstOrDefault(); if (ddlAddProduct.SelectedItem.Text != ("") && txtAddCount.Text != ("")) { if (existing != null) { existing.Count += Convert.ToInt32(txtAddCount.Text); //existing.BillNo = ddlAddBillno.Text; //existing.VendorID = Convert.ToInt32(ddlAddvendor.SelectedValue); //existing.ThreshHold += Convert.ToInt32(txtAddthresh.Text); existing.LastUpdationTime = DateTime.Now; existing.LastUpdatedBy = "admin"; existing.TenantId = tenantId; itemRepo.Edit(existing); itemRepo.Save(); gvItemDetails.EditIndex = -1; updatingitem(); BindData(); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Stock Sucessfully Updated');", true); BindData(); } else { Domain.Item item = new Domain.Item() { ProductId = Convert.ToInt32(ddlAddProduct.SelectedValue), //VendorID = Convert.ToInt32(ddlAddvendor.SelectedValue), // BillNo =ddlAddBillno.Text, Count = Convert.ToInt32(txtAddCount.Text), //ThreshHold = Convert.ToInt32(txtAddthresh.Text), CreationTime = puchasedate, LastUpdationTime = puchasedate, CreatedBy = "admin", LastUpdatedBy = "admin", TenantId = tenantId, }; itemRepo.Add(item); itemRepo.Save(); updatingitem(); BindData(); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Stock Sucessfully Inserted');", true); BindData(); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true); } //ddlAddProduct = Find(p => p.ProductId == productid).FirstOrDefault(); } } } catch (Exception ex) { Response.Write(ex.Message); } }