Beispiel #1
0
        public ActionResult DatHang()
        {
            //Thêm đơn hàng
            bill      bill = new bill();
            KhachHang kh   = (KhachHang)Session["TaiKhoan"];
            //if (Session["TaiKhoan"] == null)
            //{
            //    return RedirectToAction("DangNhap", "Home");
            //}
            //if (Session["GioHang"] == null)
            //{
            //    RedirectToAction("Index", "Home");
            //}
            List <GioHang> gh = LayGioHang();

            bill.MaKH = kh.MaKH;

            bill.MaKH       = kh.MaKH;
            bill.date_order = DateTime.Now;
            db.bills.Add(bill);
            db.SaveChanges();
            // Them chi tiết đơn hàng
            foreach (var item in gh)
            {
                bill_detail bill_Detail = new bill_detail();
                bill_Detail.id_bill    = bill.id_bill;
                bill_Detail.id_product = item.id_product;
                bill_Detail.quantity   = item.quantity;
                bill_Detail.unit_price = (int)item.unit_price;
                db.bill_detail.Add(bill_Detail);
            }
            db.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #2
0
        public static bool payAndInsertDetailBill(DataGridView dgv, bill bil)
        {
            MessageBox.Show("Toan 3");
            bool check = false;;
            int  i     = 0;

            for (i = 0; i < dgv.Rows.Count; i++)
            {
                check = false;
                detailBill detaiBill = new detailBill();
                detaiBill.IdBill    = bil.IdBill;
                detaiBill.IdProduct = int.Parse(dgv.Rows[i].Cells["idsp"].Value.ToString());
                detaiBill.Price     = int.Parse(dgv.Rows[i].Cells["giaban"].Value.ToString());
                detaiBill.Quantity  = int.Parse(dgv.Rows[i].Cells["soluong"].Value.ToString());

                string sql = "insert into CHITIETHOADON values('" + detaiBill.IdBill + "','" + detaiBill.IdProduct + "','" + detaiBill.Price + "','" + detaiBill.Quantity + "')";
                if (ConnectDAO.queryNonQuery(sql))
                {
                    check = true;
                }
                if (!check)
                {
                    break;
                }


                //Console.WriteLine("chi tuet HOA DON");
                //Console.WriteLine(" ma ct HOA DON" + detaiBill.IdBill);
                //Console.WriteLine(" id san pham" + detaiBill.IdProduct);
                //Console.WriteLine("gia" + detaiBill.Price);
                //Console.WriteLine("sol luong" + detaiBill.Quantity);
            }

            return(check);
        }
        public IHttpActionResult Putbill(int id, bill bill)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            if (id != bill.bill_Id)
            {
                return(this.BadRequest());
            }

            this.db.Entry(bill).State = EntityState.Modified;
            var billExists = this.db.bills.Count(e => e.bill_Id == id) > 0;

            try
            {
                this.db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!billExists)
                {
                    return(this.NotFound());
                }
                throw;
            }

            return(this.StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        public void AddProject(project newProject)
        {
            employee emp     = _db.employees.SingleOrDefault(x => x.empId == newProject.employeerId);
            bill     newBill = new bill();

            newBill.name     = emp.name;
            newBill.dateSell = DateTime.Now;
            _db.bills.Add(newBill);
            _db.SaveChanges();

            bill bil     = _db.bills.OrderByDescending(x => x.billId).FirstOrDefault();
            sale newSale = new sale();

            newSale.IsPaidAll = false;
            newSale.billId    = bil.billId;
            _db.sales.Add(newSale);
            _db.SaveChanges();

            sale sal = _db.sales.OrderByDescending(x => x.saleId).FirstOrDefault();

            newProject.percentStatu = 0;
            newProject.saleId       = sal.saleId;
            _db.projects.Add(newProject);
            _db.SaveChanges();
        }
Beispiel #5
0
        private void SaveServiceStatistic(bill billFromDb)
        {
            foreach (var service in billFromDb.clinic_service)
            {
                if (service.Medicine_Id != null)
                {
                    service.medicine.quantity_in_sale_unit -= 1;

                    var serviceStatistic = _clinicEntities.ServiceStatistics
                                           .Where(s => s.ServiceId == service.id && s.IsActive == true)
                                           .FirstOrDefault();

                    if (serviceStatistic is null)
                    {
                        serviceStatistic = _clinicEntities.ServiceStatistics.Add(new ServiceStatistic()
                        {
                            ServiceId  = service.id,
                            MedicineId = Convert.ToInt32(service.Medicine_Id),
                            Count      = 0,
                            StartDate  = DateTime.Now,
                        });
                    }

                    serviceStatistic.Count++;
                }
            }
        }
        public ActionResult pay(bill ttKhachHang)
        {
            ttKhachHang.create_date = DateTime.Now.Date;
            db = new ToysDBContext();
            db.bills.Add(ttKhachHang);


            cart cart = (cart)Session["cart"];

            foreach (CartItem item in cart.lstcart)
            {
                bill_detail detail = new bill_detail();
                detail.bill_id    = ttKhachHang.id;
                detail.product_id = item.Id_Product;
                detail.amount     = item.Amount;
                detail.price      = item.Amount * item.price;
                db.bill_detail.Add(detail);
            }

            int    stt     = db.SaveChanges();
            string message = "Có lỗi khi đặt hàng!";            if (stt > 0)

            {
                message = "Đặt hàng thành công";
            }
            Session["message"] = message;
            Session["Cart"]    = null;

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #7
0
        public Response SaveBillDetails(billDetails obj)
        {
            List <billDetails> weighList = new List <billDetails>();
            var  currentUser             = System.Web.HttpContext.Current.Session["employeeName"].ToString();
            bill billObj = new bill();

            billObj.dateBill            = obj.dateBill;
            billObj.toName              = obj.toName;
            billObj.addLine1            = obj.addLine1;
            billObj.addLine2            = obj.addLine2;
            billObj.addLine3            = obj.addLine3;
            billObj.transportMode       = obj.transportMode;
            billObj.vehicleNoBill       = obj.vehicleNoBill;
            billObj.placeOfDeliveryBill = obj.placeOfDeliveryBill;
            billObj.materialDescription = obj.materialDescription;
            billObj.netWeightQty        = obj.netWeightQty;
            billObj.amountBill          = obj.amountBill;
            billObj.rateBill            = obj.rateBill;
            billObj.totalInWords        = obj.totalInWords;
            billObj.cgst       = obj.cgst;
            billObj.sgst       = obj.sgst;
            billObj.mainTotal  = obj.mainTotal;
            billObj.createdBy  = currentUser;
            billObj.createdOn  = DateTime.Now;
            billObj.modifiedBy = currentUser;
            billObj.ModifiedOn = DateTime.Now;
            entities.bills.Add(billObj);
            entities.SaveChanges();
            long id = billObj.billNo;

            return(new Response {
                IsSuccess = true, Message = "Bill details added", ReturnId = id
            });
        }
Beispiel #8
0
        public bool deleteBill(int id_bill)
        {
            bill Bill   = new bill();
            bool result = Bill.Delete(id_bill);

            return(result);
        }
Beispiel #9
0
        public ActionResult Delete(int ExpenseID)
        {
            expense expense = ExpenseRepository.GetExpenseByID(ExpenseID);

            if (expense.PendingBillID > 0)
            {
                //reset bill status
                bill b = db.bills.Find(expense.PendingBillID);
                b.Status = "New";
                db.SaveChanges();
            }
            //get pending bills
            IEnumerable <bill> bills = BillRepository.GetAllBill();

            ViewBag.PendingBills = bills;
            //get pedning expenses
            IEnumerable <expense> expenses = db.expenses.Where(e => e.Status == "Unpaid");

            foreach (var i in expenses)
            {
                i.subcategory = SubCategoryRepository.GetBySubCategoryID(i.subCategoryID);
                i.bankaccount = BankAccountRepository.GetBankAccountByID(i.bankAccountID);
            }
            ViewBag.PendingExpenses = expenses;
            ViewBag.ExpenseID       = ExpenseID;

            expense.subcategory = SubCategoryRepository.GetBySubCategoryID(expense.subCategoryID);
            return(PartialView(expense));
        }
Beispiel #10
0
        static void Withdrawl(string[] options)
        {
            if (!options.Any())
            {
                Console.WriteLine("Failure: Invalid Arguments \n");
                return;
            }

            //check if amount starts with $ then remove it.
            string amount = options[0];

            if (!amount.StartsWith("$"))
            {
                Console.WriteLine("Failure: Invalid Arguments \n");
                return;
            }

            int amountRemaining;

            if (!Int32.TryParse(amount.TrimStart('$'), out amountRemaining))
            {
                Console.WriteLine("Failure: Invalid Arguments \n");
                return;
            }

            //Machine has finite funds,
            //queue up action and verify before moving money
            List <bill> queue = new List <bill>();

            foreach (bill money in stock)
            {
                int count = (int)(amountRemaining / money.value);
                if (count > money.amount)
                {
                    count = money.amount;
                }

                if (count != 0)
                {
                    amountRemaining -= count * money.value;
                    queue.Add(new bill(money.value, count));
                }
            }

            if (amountRemaining > 0)
            {
                Console.WriteLine("Failure: insufficient funds \n");
                return;
            }

            //apply queued up action against the current stock.
            foreach (bill money in queue)
            {
                bill item = stock.Find(x => x.value == money.value);
                item.amount -= money.amount;
            }

            Console.WriteLine("Success: Dispensed {0}", amount);
            DisplayBalance();
        }
Beispiel #11
0
        public bool updateBill(int id_bill, string status_bill, DateTime dayCreate_bill, string note_bill, float price_bill, float debt_bill)
        {
            bill Bill   = new bill();
            bool result = Bill.Update(id_bill, status_bill, dayCreate_bill, note_bill, price_bill, debt_bill);

            return(result);
        }
Beispiel #12
0
 public ActionResult Edit(bill bill)
 {
     if (bill.Comment == null)
     {
         bill.Comment = "";
     }
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(bill).State = EntityState.Modified;
             db.SaveChanges();
             TempData["Message2"] = string.Format("{0} record update successfully.", bill.PayeeName);
             GetData();
             if (bill.ReturnType == "List")
             {
                 return(RedirectToAction("List", new { bDate = bill.ReturnBeginDate, eDate = bill.ReturnEndDate, codeID = bill.ReturnBillID }));
             }
             else
             {
                 return(RedirectToAction("Create"));
             }
         }
     }
     catch (Exception ex)
     {
         TempData["Message2"] = string.Format("Error editing {0} record.", bill.PayeeName);
     }
     GetData();
     return(PartialView(bill));
 }
Beispiel #13
0
        public ActionResult DeleteConfirmed(int id, int page)
        {
            bill bill = _billService.FindById(id);

            _billService.Delete(bill);
            return(RedirectToAction("Index/?page=" + page));
        }
Beispiel #14
0
 public static void insert(bill m)
 {
     using (var data = new instDataContext())
     {
         data.bills.InsertOnSubmit(m);
         data.SubmitChanges();
     }
 }
Beispiel #15
0
        public ActionResult Delete(int BillID)
        {
            ViewBag.BillID = BillID;
            bill bill = billRepository.GetBillByID(BillID);

            bill.payee = PayeeRepository.GetPayeeByID(bill.payeeID);
            return(PartialView(bill));
        }
Beispiel #16
0
 public static void insert(bill m)
 {
     using (var data = new instDataContext())
     {
         data.bills.InsertOnSubmit(m);
         data.SubmitChanges();
     }
 }
Beispiel #17
0
        public long AddBill(bill bill)
        {
            db.bills.Add(bill);
            db.SaveChanges();
            var idbill = bill.id;

            return(idbill);
        }
        public ActionResult Create(bill bill)
        {
            // Dua du lieu vao dropdownlist
            ViewBag.id_type_product = new SelectList(db.type_product.ToList(), "id_type_product", "name_type_product");


            return(View());
        }
Beispiel #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            bill bill = db.bill.Find(id);

            db.bill.Remove(bill);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #20
0
        public void GetUnpaidBillByPatientId_NoneExistsPatientId_ReturnsNull()
        {
            int patientId = -1;

            bill actual = _sut.GetUnpaidBillByPatientId(patientId);

            actual.Should().BeNull();
        }
Beispiel #21
0
 public static void createBill(DataGridView dgvBil,bill bil)
 {
     if(DAO.payDAO.payAndInsertBill(bil))
         if (DAO.payDAO.payAndInsertDetailBill(dgvBil, bil))
         {
             MessageBox.Show("ok");
         }
 }
Beispiel #22
0
 public ActionResult Create(bill Bill)
 {
     using (DBModel dBModel = new DBModel())
     {
         dbmodel.bills.Add(Bill);
         dbmodel.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Beispiel #23
0
        //thêm bill
        public void addBill(bill bill)
        {
            db = new CitiZoneDataContext();
            bill bl = new bill();

            bl = bill;
            db.bills.InsertOnSubmit(bl);
            db.SubmitChanges();
        }
Beispiel #24
0
        public void PayBill_ValidBillId_ChangesBillStatus()
        {
            int id          = 1;
            var billUpdated = new bill();

            _sut.PayBill(id);

            billUpdated.Should().BeOfType <bill>().Which.is_paid.Should().BeTrue();
        }
Beispiel #25
0
        public string GetBillByToken(string token)
        {
            DBShopDataContext db = new DBShopDataContext();
            bill bill            = db.bills.FirstOrDefault(x => x.token.Equals(token));

            bill.bill_details.Clear();
            bill.customer = null;
            return(bill.ParserJSon());
        }
Beispiel #26
0
        //
        // GET: /bill/Delete/5

        public ActionResult Delete(int id = 0)
        {
            bill bill = db.bill.Find(id);

            if (bill == null)
            {
                return(HttpNotFound());
            }
            return(View(bill));
        }
Beispiel #27
0
        //xoá bill
        public void deleteBill(bill bill)
        {
            db = new CitiZoneDataContext();
            bill bl = new bill();

            bl = bill;
            bl = db.bills.Single(x => x.billID == bill.billID);
            db.bills.DeleteOnSubmit(bl);
            db.SubmitChanges();
        }
Beispiel #28
0
 public ActionResult Edit(bill bill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.client = new SelectList(db.client, "id", "identification", bill.client);
     return(View(bill));
 }
Beispiel #29
0
        //
        // GET: /bill/Edit/5

        public ActionResult Edit(int id = 0)
        {
            bill bill = db.bill.Find(id);

            if (bill == null)
            {
                return(HttpNotFound());
            }
            ViewBag.client = new SelectList(db.client, "id", "identification", bill.client);
            return(View(bill));
        }
Beispiel #30
0
 public ActionResult Edit([Bind(Include = "bill_id,bill_date,Payment,Amount,po_id")] bill bill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.po_id = new SelectList(db.purchase_order, "po_id", "po_id", bill.po_id);
     return(View(bill));
 }
 public ActionResult Edit([Bind(Include = "bills_id,price,tax,vosoli,date_bank,orders_id")] bill bill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.orders_id = new SelectList(db.orders, "orders_id", "orders_id", bill.orders_id);
     return(View(bill));
 }
Beispiel #32
0
 public static void update(bill m)
 {
     using (var data = new instDataContext())
     {
         var obj = data.bills.Single(j => j.bid == m.bid);
         obj.bdate = m.bdate;
         obj.bammount = m.bammount;
         obj.bname = m.bname;
         data.SubmitChanges();
     }
 }
 partial void Deletebill(bill instance);
 partial void Updatebill(bill instance);
 partial void Insertbill(bill instance);