public Bill_DetailsDTO(Bill_Details a) { this.ProductID = a.ProductID; this.BillID = a.BillID; this.Amount = a.Amount; this.Price = a.Price; }
//Xóa public bool Delete(string id) { Bill_Details dbEntry = shopModel.Bill_Details.Find(id); if (dbEntry == null) { return(false); } shopModel.Bill_Details.Remove(dbEntry); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddBill_Details(Bill_Details model) { Bill_Details db = shopModel.Bill_Details.Find(model.id); if (db != null) { return(false); } shopModel.Bill_Details.Add(model); shopModel.SaveChanges(); return(true); }
//Sửa public bool Update(Bill_Details model) { Bill_Details dbEntry = shopModel.Bill_Details.Find(model.id); if (dbEntry == null) { return(false); } dbEntry.id = model.id; dbEntry.id_Product = model.id_Product; dbEntry.id_bill = model.id_bill; dbEntry.total_price = model.total_price; dbEntry.quantity = model.quantity; shopModel.SaveChanges(); return(true); }
private void btn_Save_Click(object sender, EventArgs e) { if (table.Rows.Count > 0) { Bill bill = new Bill(); bill.customer_Name = txt_CusName.ToString(); bill.customer_Address = rch_cusAddress.ToString(); bill.customer_Mobile = txt_cusMobile.ToString(); bill.bill_Date = Convert.ToDateTime(dt_billDate); bill.pdt_Count = Convert.ToInt16(txt_pdtCount); bill.pdt_QuantityCount = Convert.ToInt16(txt_QuantCount); db.Bills.Add(bill); db.SaveChanges(); for (int i = 0; i < table.Rows.Count; i++) { Bill_Details billDetails = new Bill_Details(); billDetails.bill_Id = bill.bill_Id; billDetails.pdt_Id = table.Rows[i]["Items"].ToString(); billDetails.pdt_Name = table.Rows[i]["Name"].ToString(); billDetails.pdt_Rate = Convert.ToDecimal(table.Rows[i]["Rate"]); billDetails.pdt_GST = Convert.ToDecimal(table.Rows[i]["Tax GST"]); billDetails.pdt_Qauntity = Convert.ToInt16(table.Rows[i]["Quatity"]); billDetails.pdt_Discount = Convert.ToInt16(table.Rows[i]["Discount"]); db.Bill_Details.Add(billDetails); db.SaveChanges(); } MessageBox.Show("Record Succussfully created"); } else { MessageBox.Show("Please Add items"); } }
public ActionResult Payment(string shipName, string mobile, string address, string email) { var order = new Bill(); order.date = DateTime.Now; order.address = address; order.phone = mobile; order.name = shipName; order.email = email; try { var id = new BillDao().AddBill(order); var cart = (List <CartItem>)Session[CommonConstants.CartSession]; var detailDao = new Bill_DetailsDao(); double total = 0; foreach (var item in cart) { var orderDetail = new Bill_Details(); orderDetail.id_Product = item.product.id; orderDetail.id_bill = id; orderDetail.total_price = item.product.new_price; orderDetail.quantity = item.Quantity; detailDao.AddBill_Details(orderDetail); total += (item.product.new_price.GetValueOrDefault(0) * item.Quantity); } Session[CommonConstants.CartSession] = null; } catch (Exception ex) { //ghi log return(Redirect("/Payment")); } return(Redirect("/Success")); }
private void Customer_BillDetails_Load(object sender, EventArgs e) { if (Bill_Type.ToString().Contains("بيع")) { panel4.Visible = false; using (dataSet = Ezzat.GetDataSet("select_Customer_BillDetails2", "X", new SqlParameter("@Bill_ID", Bill_ID), new SqlParameter("@Bill_Type", false))) { dataGridView1.DataSource = dataSet.Tables["X"]; } SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Purchasing", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label2.Text = dataReader[0].ToString(); label12.Text = dataReader[2].ToString(); tb_BillTotal.Text = dataReader[4].ToString(); tb_Discount.Text = dataReader[5].ToString(); tb_AfterDiscount.Text = dataReader[6].ToString(); tb_OldMoney.Text = dataReader[7].ToString(); tb_Total.Text = dataReader[8].ToString(); tb_payment.Text = dataReader[9].ToString(); tb_render.Text = dataReader[10].ToString(); textBox1.Text = dataReader[3].ToString(); textBox2.Text = dataReader[12].ToString(); tb_owner.Text = dataReader[13].ToString(); richTextBox1.Text = Bill_Details.ToString(); } } con.Close(); } else if (Bill_Type.ToString().Contains("مرتجع")) { label11.Visible = label3.Visible = tb_render.Visible = textBox2.Visible = false; panel4.Visible = false; using (dataSet = Ezzat.GetDataSet("select_Customer_BillDetails", "X", new SqlParameter("@Bill_ID", Bill_ID), new SqlParameter("@Bill_Type", true))) { dataGridView1.DataSource = dataSet.Tables["X"]; dataGridView1.Columns[7].Visible = false; dataGridView1.Columns[8].Visible = false; } SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Returning", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label2.Text = dataReader[0].ToString(); label12.Text = dataReader[2].ToString(); tb_BillTotal.Text = dataReader[4].ToString(); tb_Discount.Text = dataReader[5].ToString(); tb_AfterDiscount.Text = dataReader[6].ToString(); tb_OldMoney.Text = dataReader[7].ToString(); tb_Total.Text = dataReader[8].ToString(); tb_payment.Text = dataReader[9].ToString(); textBox1.Text = dataReader[3].ToString(); tb_owner.Text = dataReader[11].ToString(); richTextBox1.Text = Bill_Details.ToString(); } } con.Close(); } else if (Bill_Type.ToString().Contains("تحويل بنكى")) { SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Bank", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label21.Text = dataReader[0].ToString(); label16.Text = dataReader[2].ToString(); tb_old.Text = dataReader[4].ToString(); tb_pay.Text = dataReader[5].ToString(); tb_after.Text = dataReader[6].ToString(); richTextBox2.Text = dataReader[7].ToString(); textBox4.Text = dataReader[8].ToString(); textBox3.Text = dataReader[10].ToString(); } } con.Close(); } else if (Bill_Type.ToString().Contains("تسديد")) { SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Payback", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label21.Text = dataReader[0].ToString(); label16.Text = dataReader[2].ToString(); tb_old.Text = dataReader[4].ToString(); tb_pay.Text = dataReader[5].ToString(); tb_after.Text = dataReader[6].ToString(); richTextBox2.Text = dataReader[7].ToString(); textBox4.Visible = label24.Visible = false; textBox3.Text = dataReader[10].ToString(); } } con.Close(); } else if (Bill_Type.ToString().Contains("خصم")) { SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Discount", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label21.Text = dataReader[0].ToString(); label16.Text = dataReader[2].ToString(); tb_old.Text = dataReader[3].ToString(); tb_pay.Text = dataReader[4].ToString(); tb_after.Text = dataReader[5].ToString(); richTextBox2.Text = dataReader[6].ToString(); textBox4.Visible = label24.Visible = false; textBox3.Text = dataReader[7].ToString(); } } con.Close(); } else if (Bill_Type.ToString().Contains("تحويل الى مورد")) { SqlConnection con; SqlDataReader dataReader = Ezzat.GetDataReader("select_EXBillDeteils_Trans", out con, new SqlParameter("@Bill_ID", Bill_ID)); if (dataReader.HasRows) { while (dataReader.Read()) { label21.Text = dataReader[0].ToString(); label16.Text = dataReader[2].ToString(); tb_old.Text = dataReader[4].ToString(); tb_pay.Text = dataReader[5].ToString(); tb_after.Text = dataReader[6].ToString(); richTextBox2.Text = dataReader[7].ToString(); textBox4.Text = dataReader[8].ToString(); textBox3.Text = dataReader[9].ToString(); } } con.Close(); } }
//Lấy theo id public Bill_Details getByID(string id) { Bill_Details Bill_Details = shopModel.Bill_Details.Find(id); return(Bill_Details); }