protected void addItem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddItem") { int rowIndex = Convert.ToInt32(e.CommandArgument); TextBox tb = (TextBox)GridStationery.Rows[rowIndex].FindControl("Quantity"); String qty = tb.Text; HiddenField itemNumerHdden = (HiddenField)GridStationery.Rows[rowIndex].FindControl("HiddenField1"); String productid = itemNumerHdden.Value; Stationery_Catalogue product = Stationery_Catalogue_DAO.GetStationeryCatalogueByItemId(productid); product.Total_Quantity = (Convert.ToInt32(qty)); Stationery_Catalogue existingproduct = null; foreach (Stationery_Catalogue stationery_catalogue in selectedproductList) { if (stationery_catalogue.Item_Number == productid) { existingproduct = stationery_catalogue; break; } } if (existingproduct != null) { existingproduct.Total_Quantity = existingproduct.Total_Quantity + product.Total_Quantity; } else { selectedproductList.Add(product); } Session["Cart"] = selectedproductList; } }
protected void addItem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddItem") { String rowIndex = e.CommandArgument.ToString(); HiddenField itemNumerHdden = (HiddenField)GridView1.Rows[Convert.ToInt32(rowIndex)].FindControl("HiddenField1"); String productid = itemNumerHdden.Value; TextBox tb = (TextBox)GridView1.Rows[Convert.ToInt32(rowIndex)].FindControl("Quantity"); String qty = tb.Text; Stationery_Catalogue product = ssisEntities.Stationery_Catalogue.Where(x => x.Item_Number == productid).First(); product.Total_Quantity = (Convert.ToInt32(qty)); Stationery_Catalogue existingproduct = null; foreach (Stationery_Catalogue stationery_catalogue in selectedproductList) { if (stationery_catalogue.Item_Number == productid) { existingproduct = stationery_catalogue; break; } } if (existingproduct != null) { existingproduct.Total_Quantity = existingproduct.Total_Quantity + product.Total_Quantity; } else { selectedproductList.Add(product); } Session["Cart"] = selectedproductList; } }
protected void Page_Load(object sender, EventArgs e) { String supplierID = Request.QueryString["supplier_id"]; item_number = Request.QueryString["item_Number"]; orderid = Request.QueryString["order_id"]; string sts = Request.QueryString["status"]; ord = Convert.ToInt32(orderid); Supplier s = model.Suppliers.Where(x => x.Supplier_ID == supplierID).First(); lblsupname.Text = s.Supplier_Name; lblfax.Text = s.Fax_Number.ToString(); lblcontanct.Text = s.Contact_Number.ToString(); lblorderID.Text = orderid; lblstatus.Text = sts; var podetail = model.Purchase_Order_Details.Where(x => x.Order_ID == ord && x.Item_Number == item_number).Select(x => x.Quantity).First(); lblqty.Text = podetail.ToString(); iteminfo = model.Stationery_Catalogue.Where(x => x.Item_Number == item_number).First(); lblcategory.Text = iteminfo.Category; lbldescription.Text = iteminfo.Description; lblunitprice.Text = iteminfo.Price.ToString(); int qty = Convert.ToInt32(iteminfo.Reorder_Quantity); Double unitprice = ((double)podetail / (double)qty); Double total = (Double)((Double)iteminfo.Price * (double)unitprice); lbltotal.Text = total.ToString(); DateTime today = DateTime.Today; if (today.DayOfWeek == DayOfWeek.Monday) { lbldelivery.Text = today.ToString(); } else { int daysmonday = ((int)DayOfWeek.Monday - (int)today.DayOfWeek + 7) % 7; DateTime monday = today.AddDays(daysmonday); lbldelivery.Text = DeliveryDate.getDeliveryDate(); /*monday.ToString();*/ } orderdetail = model.Purchase_Order_Details.Where(x => x.Order_ID == ord && x.Item_Number == item_number).First(); string status = orderdetail.Status; if (status.Equals("Purchased") || status.Equals("Forwarded")) { btnSendInvoice.Visible = false; btnAddtoStock.Visible = false; } orderdetail = model.Purchase_Order_Details.Where(x => x.Order_ID == ord && x.Item_Number == item_number).First(); Random r = new Random(); int invoicenp = r.Next(1000000, 9999999); lblInvoice.Text = invoicenp.ToString(); }
protected void Quantity_ChangeTextBox(object sender, EventArgs e) { HiddenField hiddenField1 = (HiddenField)(GridStationeryCart.Rows[0].FindControl("HiddenItemNumber")); String itemID = hiddenField1.Value; TextBox qtyText = (TextBox)(GridStationeryCart.Rows[0].FindControl("Quantity")); String qty = qtyText.Text; Stationery_Catalogue product = null; foreach (Stationery_Catalogue stationery_catalogue in cartList) { if (stationery_catalogue.Item_Number == itemID) { product = stationery_catalogue; break; } } product.Total_Quantity = Convert.ToInt32(qty); }
protected void Button1_Click(object sender, EventArgs e) { SSISEntities model = new SSISEntities(); var stationery = new Stationery_Catalogue(); string item = txtItemNumber.Text; //get inital string unoperated = txtDescription.Text; string first = unoperated.Substring(0, 1).ToUpper(); item = first + item; if (model.Stationery_Catalogue.Where(x => x.Item_Number == item).FirstOrDefault() != null) { //check item already exist or not! ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('This item already exist !');window.location ='AddStationeryCatalogue.aspx';", true); } else { //insert to the database stationery.Item_Number = item; stationery.Category = dropCategory.SelectedValue.ToString(); stationery.Description = txtDescription.Text; stationery.Reorder_Level = Convert.ToInt32(txtReorderLevel.Text); stationery.Reorder_Quantity = Convert.ToInt32(txtReorderQuantity.Text); stationery.Measure_Unit = UnitMeasure.SelectedValue.ToString(); stationery.Price = Convert.ToDouble(txtPrice.Text); stationery.Total_Quantity = Convert.ToInt32(txtTotal.Text); model.Stationery_Catalogue.Add(stationery); model.SaveChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Successfully Added');window.location ='Store_StationeryCatalogue.aspx';", true); txtItemNumber.Text = ""; txtDescription.Text = ""; txtReorderLevel.Text = ""; txtReorderQuantity.Text = ""; txtPrice.Text = ""; txtTotal.Text = ""; } }
protected void GridViewCatalogue_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddToCart") { String item = e.CommandArgument.ToString(); Stationery_Catalogue st = model.Stationery_Catalogue.Where(x => x.Item_Number == item).First(); bool rpItem = false; int qty = Convert.ToInt32(st.Reorder_Level); double price = Convert.ToDouble(st.Price); foreach (Stationery_Catalogue a in stationery) { if (a.Item_Number == st.Item_Number) { rpItem = true; } } if (!rpItem) { stationery.Add(st); Session["Shoppingcart"] = stationery; count = (int)Session["ShoppingCartCount"]; count++; Session["ShoppingCartCount"] = count; //qty and total shoppingcartqty.Add(qty); shoppingcartTotal.Add(price); Session["totalqty"] = shoppingcartqty; Session["totalprice"] = shoppingcartTotal; Response.Redirect("Store_SupplierforItems.aspx?item_Number=" + item); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('This item is Already Exist');window.location ='Store_MakePurchaseOrder.aspx';", true); } } }
protected void Button1_Click(object sender, EventArgs e) { string Description = DropDownList1.SelectedItem.ToString(); string Rank = RadioButtonList1.SelectedValue; string ItemNo; //try //{ using (SSISEntities entity = new SSISEntities()) { string stationeryCata = entity.Stationery_Catalogue.Where(p => p.Description == Description).Select(p => p.Item_Number).First().ToString(); Supplier_Item supplier_Item = entity.Supplier_Item.Where(y => y.Item_Number == stationeryCata).First(); ItemNo = entity.Stationery_Catalogue.Where(k => k.Description == Description).Select(k => k.Item_Number).First().ToString(); supplier_Item.Supplier_ID = suppliername.ToString(); supplier_Item.Rank = Rank.ToString(); supplier_Item.Price = Double.Parse(TextBox1.Text); entity.SaveChanges(); Save(); } using (SSISEntities entity = new SSISEntities()) { if (Rank.ToString() == "1") { Stationery_Catalogue sc = entity.Stationery_Catalogue.Where(s => s.Item_Number == ItemNo).First(); sc.Price = Double.Parse(TextBox1.Text); entity.SaveChanges(); Save(); } } //} //catch (Exception exp) //{ // Response.Write(exp.ToString()); //} Response.Redirect("~/com.ssis.PurchaseDepartmentRepresentative/MaintainSupplierInformation.aspx"); }
protected void remove_ItemRowCommand(object sender, GridViewCommandEventArgs e) { TextBox tb = (TextBox)GridStationeryCart.Rows[0].FindControl("Quantity"); String qty = tb.Text; if (e.CommandName == "editQuantity") { String itemID = e.CommandArgument.ToString(); Stationery_Catalogue product = null; foreach (Stationery_Catalogue stationery_catalogue in cartList) { if (stationery_catalogue.Item_Number == itemID) { product = stationery_catalogue; break; } } product.Total_Quantity = Convert.ToInt32(qty); } else if (e.CommandName == "remove") { String itemID = e.CommandArgument.ToString(); Stationery_Catalogue product = null; foreach (Stationery_Catalogue stationery_catalogue in cartList) { if (stationery_catalogue.Item_Number == itemID) { product = stationery_catalogue; break; } } cartList.Remove(product); Session["Cart"] = cartList; refereshDataGrid(); } }
public static Stationery_Catalogue GetStationeryCatalogueByItemId(String itemID) { Stationery_Catalogue product = ssisEntities.Stationery_Catalogue.Where(x => x.Item_Number == itemID).First(); return(product); }