Esempio n. 1
0
        //xóa hoặc giảm số lượng sản phẩm từ cart
        void DeleteCart()
        {
            string     delete      = (string)Request.Form["delete"];
            ExportBill eb          = (ExportBill)Session["cart"];
            string     rawDeleteId = (string)Request.Form["id"];
            int        deleteId    = Convert.ToInt32(rawDeleteId);

            for (int i = 0; i < eb.Lines.Count; i++)
            {
                DetailExportBill detail = eb.Lines[i];
                if (deleteId == detail.Product.Id)
                {
                    if (detail.Quantity > 1)
                    {
                        detail.Quantity = (detail.Quantity - 1);
                        detail.Discount = 0;
                    }
                    else
                    {
                        eb.Lines.RemoveAt(i);
                    }
                    break;
                }
            }
            Session["cart"] = eb;
        }
Esempio n. 2
0
        //giảm giá
        void FromDiscount()
        {
            string     frmDiscount      = Request.Form["frmDiscount"];
            int        index            = Convert.ToInt32(frmDiscount);
            ExportBill eb               = (ExportBill)Session["cart"];
            string     rawValueDiscount = Request.Form["valueDiscount"];
            float      valueDiscount    = Convert.ToSingle(rawValueDiscount);

            eb.Lines[index].Discount = (eb.Lines[index].ToTalPrice * eb.Lines[index].Quantity * valueDiscount) / 100;
            Session["cart"]          = eb;
        }
Esempio n. 3
0
        public void ViewDetailOrder()
        {
            string           rawId    = (string)Request.Form["id"];
            int              detailID = Convert.ToInt32(rawId);
            ExportBillDAO    exDAO    = new ExportBillDAO();
            ExportBill       ex       = new ExportBill();
            DetailExportBill de       = new DetailExportBill();

            Session["detailInfo"]  = exDAO.GetExportBillByID(detailID);
            Session["detailOrder"] = exDAO.GetDetailExportBillByID(detailID);
        }
Esempio n. 4
0
        public bool Insert(ExportBill entity)
        {
            db.ExportBills.Add(entity);
            int isSave = db.SaveChanges();

            if (isSave > 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        public ExportBill getID(long ID)
        {
            try
            {
                ExportBill entity = db.ExportBills.Find(ID);
                return(entity);
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
        public ExportBill getExportBill(SqlConnection con, int ExportBillID)
        {
            ExportBill objExB = null;

            try
            {
                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter("Select * FROM T_Export_Bill WHERE BillID=" + ExportBillID.ToString(), con);
                da.Fill(dt);
                da.Dispose();

                if (dt.Rows.Count == 0)
                {
                    return(null);
                }
                objExB        = new ExportBill();
                objExB.BillID = dt.Rows[0].Field <int>("BillID");

                objExB.BillType = dt.Rows[0].Field <string>("BillType");
                objExB.BillNo   = dt.Rows[0].Field <string>("TypeNo");

                objExB.LCID       = dt.Rows[0].Field <object>("LCID") == DBNull.Value || dt.Rows[0].Field <object>("LCID") == null ? -1 : dt.Rows[0].Field <int>("LCID");
                objExB.LCValue    = Convert.ToDouble(dt.Rows[0].Field <object>("LCValue"));
                objExB.CurrencyID = dt.Rows[0].Field <object>("CurrencyID") == DBNull.Value || dt.Rows[0].Field <object>("CurrencyID") == null ? -1 : dt.Rows[0].Field <int>("CurrencyID");
                objExB.LCQuantity = Convert.ToDouble(dt.Rows[0].Field <object>("LCQty"));
                objExB.UnitID     = dt.Rows[0].Field <object>("UnitID") == DBNull.Value || dt.Rows[0].Field <object>("UnitID") == null ? -1 : dt.Rows[0].Field <int>("UnitID");
                objExB.BillDate   = dt.Rows[0].Field <DateTime>("BillDate");
                objExB.BillAmount = Convert.ToDouble(dt.Rows[0].Field <object>("BillAmount"));

                objExB.LoanNo           = dt.Rows[0].Field <string>("LoanNo");
                objExB.RealisedAmount   = Convert.ToDouble(dt.Rows[0].Field <object>("RealisedAmt"));
                objExB.RealisedDate     = dt.Rows[0].Field <object>("RealisedDate") == DBNull.Value || dt.Rows[0].Field <object>("RealisedDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("RealisedDate");
                objExB.RealisedLoss     = Convert.ToDouble(dt.Rows[0].Field <object>("RealisedLoss"));
                objExB.AcceptDate       = dt.Rows[0].Field <object>("AcceptDate") == DBNull.Value || dt.Rows[0].Field <object>("AcceptDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("AcceptDate");
                objExB.MaturityDate     = dt.Rows[0].Field <object>("MaturityDate") == DBNull.Value || dt.Rows[0].Field <object>("MaturityDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("MaturityDate");
                objExB.remarks          = dt.Rows[0].Field <string>("remarks");
                objExB.TransactionRefID = dt.Rows[0].Field <object>("TransRefID") == DBNull.Value || dt.Rows[0].Field <object>("TransRefID") == null ? -1 : dt.Rows[0].Field <int>("TransRefID");
                objExB.PurchaseDate     = dt.Rows[0].Field <object>("PurchaseDate") == DBNull.Value || dt.Rows[0].Field <object>("PurchaseDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("PurchaseDate");
                objExB.PurchaseAmount   = Convert.ToDouble(dt.Rows[0].Field <object>("PurchaseAmount"));
                objExB.CurrencyRate     = Convert.ToDouble(dt.Rows[0].Field <object>("CurrencyRate"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(objExB);
        }
Esempio n. 7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            ExportBill entity = new ExportBill();

            entity.ID          = IDExBill;
            entity.Bill        = txtBillName.Text;
            entity.IDWareHouse = Convert.ToInt32(cbWH.SelectedValue);
            entity.Date        = dateTimePicker.Value;
            entity.Quantity    = Convert.ToInt32(txtQuantity.Text);
            entity.TotalPrice  = Convert.ToInt32(txtMoney.Text);
            FExportBill Ex        = new FExportBill();
            var         result    = Ex.Update(entity);
            var         listolder = (from dt in db.ProductDetails.Where(x => x.IDExBill == IDExBill).ToList()
                                     from pr in db.Products.Where(x => x.ID == dt.IDProduct).ToList()
                                     from com in db.Companies.Where(x => x.ID == pr.IDCompany).ToList()
                                     select new
            {
                IDProductDetail = dt.ID,
                ID = pr.ID,
                Product1 = pr.Product1,
                Quantity = dt.Quantity,
                OrdinaryPrice = pr.OrdinaryPrice
            }
                                     ).ToList();

            foreach (var item in lprodt)
            {
                var search = listolder.Find(x => x.ID == item.IDProduct);
                if (search == null)
                {
                    FProductDetail dt = new FProductDetail();

                    dt.Insert(item);
                }
                else
                {
                    item.ID = search.IDProductDetail;
                    FProductDetail dt = new FProductDetail();
                    dt.Update(item);
                }
            }
            if (result == true)
            {
                MessageBox.Show("Sửa phiếu nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 8
0
        void checkOut()
        {
            ExportBill eb = (ExportBill)Session["cart"];

            eb.Note = Request.Form["note"];
            Staff staff = new Staff
            {
                ID = (string)Session["Name"]
            };
            Customer cus = new Customer();

            cus.ID      = Convert.ToInt32(Request.Form["cusName"]);
            eb.Staff    = staff;
            eb.Customer = cus;
            edao        = new ExportBillDAO();
            edao.insert(eb);
            eb = new ExportBill();
            Session["cart"] = eb;
        }
Esempio n. 9
0
        public bool Update(ExportBill entity)
        {
            try
            {
                var Pro = db.ExportBills.Find(entity.ID);
                Pro.Bill        = entity.Bill;
                Pro.IDWareHouse = entity.IDWareHouse;
                Pro.TotalPrice  = entity.TotalPrice;
                Pro.Quantity    = entity.Quantity;
                Pro.Date        = entity.Date;
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
            return(true);
        }
Esempio n. 10
0
        //thêm sản phẩm vào giỏ hàng
        void AddProductToCart()
        {
            string     rawId = (string)Request.Form["productId"];
            ExportBill eb    = (ExportBill)Session["cart"];

            if (eb == null)
            {
                eb = new ExportBill();
            }
            int productId = Convert.ToInt32(rawId);

            pdao = new ProductDAO();
            Product p             = pdao.GetProductById(productId);
            int     indexExisting = -1;

            for (int i = 0; i < eb.Lines.Count; i++)
            {
                DetailExportBill detail = eb.Lines[i];
                if (p.Id == detail.Product.Id)
                {
                    indexExisting = i;
                    break;
                }
            }
            if (indexExisting != -1)
            {
                DetailExportBill detail = eb.Lines[indexExisting];
                detail.Quantity = (detail.Quantity + 1);
            }
            else
            {
                DetailExportBill detail = new DetailExportBill();
                detail.Product    = p;
                detail.ExportBill = eb;
                detail.ToTalPrice = p.PriceSale;
                detail.Quantity   = 1;
                detail.Discount   = 0;
                eb.Lines.Add(detail);
            }
            Session["cart"] = eb;
        }
Esempio n. 11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ExportBill entity = new ExportBill();

            entity.Bill        = txtBillName.Text;
            entity.IDWareHouse = Convert.ToInt32(cbWH.SelectedValue);
            entity.Date        = dateTimePicker.Value;
            entity.Quantity    = Convert.ToInt32(txtQuantity.Text);
            entity.TotalPrice  = Convert.ToInt32(txtMoney.Text);
            FExportBill Ex     = new FExportBill();
            var         result = Ex.Insert(entity);

            foreach (var item in lprodt)
            {
                item.IDExBill = entity.ID;
                FProductDetail dt = new FProductDetail();
                dt.Insert(item);
            }
            if (result == true)
            {
                MessageBox.Show("Thêm phiếu nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 12
0
        public void buildExport()
        {
            Fbexplore fbexplore = new Fbexplore(ConfigurationManager.AppSettings["estream"]);

            if (!String.IsNullOrEmpty(fbexplore.LatestPath))
            {
                Console.WriteLine($"Attempting to connect to latest DB : {fbexplore.LatestPath}\n");
                try
                {
                    // ===================================
                    //  Export new invoices to kiple home
                    // ===================================

                    Console.WriteLine($"Checking invoices for the past {ConfigurationManager.AppSettings["datespan"]} days.\n");

                    Ariv         ariv     = new Ariv(fbexplore.LatestPath);
                    FbDataReader invoices = ariv.queryInvoice();

                    if (invoices.HasRows)
                    {
                        PosthocBill posthocBill = new PosthocBill(ref invoices);

                        if (posthocBill.InvoiceLst.Count() != 0)
                        {
                            Console.WriteLine($"Invoice count: {posthocBill.InvoiceLst.Count()}\n");
                            ExportBill.dump(posthocBill.InvoiceLst, 0);
                        }
                        else
                        {
                            Console.WriteLine($"No invoice(s) found for the past {ConfigurationManager.AppSettings["datespan"]} days.\n");
                        }
                    }
                    else
                    {
                        Console.WriteLine($"No invoice(s) found for the past {ConfigurationManager.AppSettings["datespan"]} days.\n");
                    }

                    // ===================================================================================
                    //  Check kiple home for pending invoices. Export payments back to kiple home if any.
                    // ===================================================================================

                    Console.WriteLine("Checking for pending payments: Connecting to Kiple Home ...\n");
                    AssertBills assertBills = new AssertBills();
                    if (!(assertBills.Bills is null) && assertBills.Bills.Count != 0)
                    {
                        Console.WriteLine($"Outstanding Bills from KipleHome : {assertBills.Bills.Count} \n");
                        UpdateBills updateBills = new UpdateBills(assertBills.Bills, fbexplore.LatestPath);
                        updateBills.exportPayment();
                    }
                    else
                    {
                        Console.WriteLine("No outstanding bills. \n");
                    }

                    // =====================================================
                    //  Check kiple home for payments made through KipleBiz
                    // =====================================================

                    Console.WriteLine("Checking for payments made via KipleHome App ... \n");
                    AdyenPayment adyenPayment = new AdyenPayment();
                    if (!(adyenPayment.Payments is null) && adyenPayment.Payments.Count != 0)
                    {
                        Console.WriteLine($"Inserting {adyenPayment.Payments.Count} payment(s) to local database ... \n");
                        MakePayment makePayment = new MakePayment(adyenPayment.Payments, fbexplore.LatestPath);
                        makePayment.insertPayments();
                    }
Esempio n. 13
0
        public ActionResult ProceedConfirmed(OrderViewModel viewModel)
        {
            //try
            //{
            int    id       = viewModel.GuitarId;
            var    date     = _DbContext.Reservation.Single(c => c.GuitarId == id);
            var    exp      = _DbContext.ExportBill.ToList();
            int    expcount = exp.Count();
            string newo     = viewModel.Des.ToString();
            var    guitar   = _DbContext.Guitars.Single(c => c.GuitarId == id);
            var    brand    = _DbContext.Brand.Single(c => c.BrandId == guitar.BrandId);
            var    use      = _DbContext.Users.Single(c => c.Id == date.UserId);

            //a.Open();
            //string gc = string.Format("select b.BrandName,G.MDL, G.MSRP from Guitars G ,Brands B where g.BrandId=b.BrandId and g.GuitarId='{0}'", viewModel.GuitarId);
            //SqlCommand y = new SqlCommand(gc, a);
            //SqlDataReader d = y.ExecuteReader();
            //dt1.Load(d);
            var expdetail = new ExpBillDetail()
            {
                //ExpBId=expcount,
                GuitarId = id,
                Cost     = guitar.MSRP,
                Product  = string.Format("" + brand.BrandName + " " + guitar.MDL)
            };
            //string z = string.Format("insert into ExpBillDetails values ('{0}','{1}','{2} {3}',{4})", expcount, dt1.Rows[0][2].ToString(), dt1.Rows[0][0].ToString(), dt1.Rows[0][1].ToString(), viewModel.GuitarId);
            //SqlCommand vaoexpbilldet = new SqlCommand(z, a);
            //vaoexpbilldet.ExecuteNonQuery();

            //string bc = string.Format("select U.FullName, u.Email, U.Address, u.PhoneNumber, r.DateReserve from AspNetUsers U, Reservations R where  R.UserId = U.Id and R.userId = '{0}'", date.UserId);
            //SqlCommand x = new SqlCommand(bc, a);
            //SqlDataReader b = x.ExecuteReader();
            //dt2.Load(b);
            var user2 = User.Identity.GetUserId();
            //var user1 = _DbContext.Users.Single(c=>c.Id=user2.)

            var expbill = new ExportBill()
            {
                //ExpBId = expcount,
                ExpDate  = DateTime.Now,
                ExpCus   = use.FullName,
                ExpCusId = date.UserId,
                ExpEmp   = _DbContext.Users.Single(c => c.Id == user2).FullName,
                ExpEmpId = User.Identity.GetUserId(),
                ExpDes   = String.Format("Customer Email:" + use.Email + "\n Customer Phone number:" + use.PhoneNumber + "\n Extra" + viewModel.Des)
            };

            //string ab = string.Format("insert into ExportBills values ('{0}',CURRENT_TIMESTAMP,'{1}','{2}','{3}','{4}',
            //'Customer Email:{5} Customer Phone number:{6} Additional Information: {7}')", expcount, User.Identity.GetUserName(), dt2.Rows[0][0].ToString(), User.Identity.GetUserId(), date.UserId.ToString(), dt2.Rows[0][1].ToString(), dt2.Rows[0][3].ToString(), newo);
            //SqlCommand vaoexpbill = new SqlCommand(ab, a);
            //vaoexpbill.ExecuteNonQuery();

            //string zu = string.Format("Update Guitars set Availability='2' where GuitarId='{0}'", viewModel.GuitarId);
            //SqlCommand cd = new SqlCommand(zu, a);
            //cd.ExecuteNonQuery();

            //a.Close();
            guitar.Availability = 2;
            _DbContext.ExpBillDetail.Add(expdetail);
            _DbContext.SaveChanges();
            _DbContext.ExportBill.Add(expbill);
            _DbContext.SaveChanges();
            _DbContext.Reservation.Remove(date);
            _DbContext.SaveChanges();
            return(RedirectToAction("List", "Order"));
            //}
            //catch
            //{
            //    return RedirectToAction("List", "Order");
            //}
        }
        public int SaveUpdateExportBill(ExportBill obExBill, SqlConnection con, SqlTransaction trans)
        {
            int        ID  = 0;
            SqlCommand com = null;

            try
            {
                com             = new SqlCommand("spSaveUpdateExportBill", con, trans);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("@BillID", SqlDbType.Int).Value           = obExBill.BillID;
                com.Parameters.Add("@BillType", SqlDbType.VarChar, 50).Value = obExBill.BillType;
                com.Parameters.Add("@TypeNo", SqlDbType.VarChar, 100).Value  = obExBill.BillNo;
                com.Parameters.Add("@LCID", SqlDbType.Int).Value             = obExBill.LCID;
                com.Parameters.Add("@LCValue", SqlDbType.Money).Value        = obExBill.LCValue;
                if (obExBill.CurrencyID <= 0)
                {
                    com.Parameters.Add("@CurrencyID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@CurrencyID", SqlDbType.Int).Value = obExBill.CurrencyID;
                }
                com.Parameters.Add("@LCQty", SqlDbType.Money).Value = obExBill.LCQuantity;
                if (obExBill.UnitID <= 0)
                {
                    com.Parameters.Add("@UnitID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@UnitID", SqlDbType.Int).Value = obExBill.UnitID;
                }
                com.Parameters.Add("@BillDate", SqlDbType.DateTime).Value   = obExBill.BillDate;
                com.Parameters.Add("@BillAmount", SqlDbType.Money).Value    = obExBill.BillAmount;
                com.Parameters.Add("@LoanNo", SqlDbType.VarChar, 100).Value = obExBill.LoanNo;
                com.Parameters.Add("@RealisedAmt", SqlDbType.Money).Value   = obExBill.RealisedAmount;
                com.Parameters.Add("@RealisedLoss", SqlDbType.Money).Value  = obExBill.RealisedLoss;
                if (obExBill.RealisedDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@RealisedDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@RealisedDate", SqlDbType.DateTime).Value = obExBill.RealisedDate;
                }
                com.Parameters.Add("@remarks", SqlDbType.VarChar, 500).Value = obExBill.remarks;
                if (obExBill.AcceptDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@AcceptDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@AcceptDate", SqlDbType.DateTime).Value = obExBill.AcceptDate;
                }
                if (obExBill.MaturityDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@MaturityDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@MaturityDate", SqlDbType.DateTime).Value = obExBill.MaturityDate;
                }

                if (obExBill.TransactionRefID <= 0)
                {
                    com.Parameters.Add("@TransRefID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@TransRefID", SqlDbType.Int).Value = obExBill.TransactionRefID;
                }

                if (obExBill.PurchaseDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value = obExBill.PurchaseDate;
                }

                com.Parameters.Add("@PurchaseAmount", SqlDbType.Money).Value = obExBill.PurchaseAmount;

                com.Parameters.Add("@CompanyID", SqlDbType.Int).Value      = LogInInfo.CompanyID;
                com.Parameters.Add("@UserID", SqlDbType.Int).Value         = LogInInfo.UserID;
                com.Parameters.Add("@CurrencyRate", SqlDbType.Money).Value = obExBill.CurrencyRate;
                com.ExecuteNonQuery();
                if (obExBill.BillID == 0)
                {
                    SqlCommand cmd = new SqlCommand("Select ISNULL(MAX(BillID),0) FROM T_Export_Bill", con, trans);
                    ID = Convert.ToInt32(cmd.ExecuteScalar());
                }
                else
                {
                    ID = obExBill.BillID;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return(ID);
        }