protected void Button1_Click(object sender, EventArgs e) { string cate = DropDownList1.SelectedValue; string des = DropDownList2.SelectedValue; string supplierCode; double price; string itemCode; Button2.Enabled = true; supplierCode = TextBox3.Text; try { supplierCode = TextBox3.Text; using (Model1 entities = new Model1()) { TenderPriceList tp = entities.TenderPriceLists.Where(p => p.SuppCode == supplierCode && p.Description == des).First(); price = (double)tp.Price; itemCode = tp.ItemCode; } int AVnumber = Convert.ToInt32(TextBox4.Text); int qty = Int32.Parse(TextBox1.Text); string reason = TextBox2.Text; string status = "Pending"; if (qty < 0) { Label8.Text = "All number must be positive"; } else { AddAdjustmentVoucherDetails(AVnumber, itemCode, des, qty, price, reason, status); BindGrid(AVnumber); Label8.Text = "Add Successful!"; Button2.Enabled = true; } } catch (Exception ex) { Label8.Text = "Please input Valid Quantity and Reason"; } }
//DDL Description protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { string description = DropDownList2.SelectedValue; Stock s = ctx.Stocks.Where(x => x.Description == description).First(); //ItemCode TextBox1.Text = s.ItemCode; //Qty int rl = s.ReorderLevel.Value; int cq = s.CurrentQty.Value; int rq = s.ReorderedQty.Value; int qty; if (cq < rl) { qty = ((rl - cq) / rq + 1) * rq; TextBox2.Text = qty.ToString(); } else { TextBox2.Text = "Stock enough"; } //Supplier RadioButton1.Checked = true; RadioButton2.Checked = false; RadioButton3.Checked = false; RadioButton1.Text = "FirstSupp:" + s.FirstSupp; RadioButton2.Text = "SecondSupp:" + s.SecondSupp; RadioButton3.Text = "ThirdSupp:" + s.ThirdSupp; Label8.Text = s.FirstSupp; //Price try { string item = TextBox1.Text; TenderPriceList p = ctx.TenderPriceLists.Where(x => x.ItemCode == item && x.SuppCode == s.FirstSupp).First(); TextBox3.Text = p.Price.ToString(); } catch (Exception ex) { } //TotalPrice TotalPrice(); }
protected void RadioButton3_CheckedChanged(object sender, EventArgs e) { string description = DropDownList2.SelectedValue; Stock s = ctx.Stocks.Where(x => x.Description == description).First(); if (RadioButton3.Checked == true) { Label8.Text = s.ThirdSupp; RadioButton1.Checked = false; RadioButton2.Checked = false; try { string item = TextBox1.Text; TenderPriceList p = ctx.TenderPriceLists.Where(x => x.ItemCode == item && x.SuppCode == s.ThirdSupp).First(); TextBox3.Text = p.Price.ToString(); } catch (Exception ex) { TextBox3.Text = ex.ToString(); } TotalPrice(); } }