private void LoadInfo(int id)
        {
            ProductBUS bus    = new ProductBUS();
            ProductDTO result = bus.LoadOneProduct(id);

            txtID.Content       = result.ID.ToString();
            txtName.Text        = result.Name;
            lblAmount.Content   = result.IvenNum.ToString();
            txtInputPrice.Text  = result.InputPrice.ToString();
            txtOutputPrice.Text = result.OutputPrice.ToString();
        }
Beispiel #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            String  productId = dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString();
            Product product   = ProductBUS.searchById(productId);

            txtId.Text        = product.id.ToString();
            txtName.Text      = product.name.ToString();
            txtCateId.Text    = product.cateid.ToString();
            txtPrice.Text     = product.price.ToString();
            txtDesc.Text      = product.description.ToString();
            txtImageLink.Text = product.imagelink.ToString();
        }
Beispiel #3
0
        public object Get(string name)
        {
            string token = Request.Headers.Authorization == null ? "" : Request.Headers.Authorization.ToString();

            Logger.Info(Request.RequestUri + "  ||  Method: " + Request.Method, Request.Headers.ToString(), null, Level.INFO);

            ResponseDTO Response = new ResponseDTO();

            Response = ProductBUS.GetAllProduct(name);

            return(Response);
        }
Beispiel #4
0
        private void FrmPosFunction_Load(object sender, EventArgs e)
        {
            ResizeWindows();

            productBUS = new ProductBUS();
            lstProduct = productBUS.GetAll();

            lstOrderProduct  = new List <Product>();
            lstOrderQuantity = new List <int>();

            LoadDanhSachSanPham();
            ResetForm();
        }
Beispiel #5
0
        private void ThemChiTietSanPham_Load(object sender, EventArgs e)
        {
            ProductBUS productBUS = new ProductBUS();

            cbTenHang.DataSource    = productBUS.LoadAllData();
            cbTenHang.DisplayMember = "Name";
            cbTenHang.ValueMember   = "ProductID";

            UnitBUS unitBUS = new UnitBUS();

            cbDonVi.DataSource    = unitBUS.LoadAllData();
            cbDonVi.ValueMember   = "UnitID";
            cbDonVi.DisplayMember = "Name";
        }
Beispiel #6
0
        // GET: Admin/Product/Delete/5
        public ActionResult Delete(int id)
        {
            var info = new ProductInfoAdmin()
            {
                SanPhamInfoAdmim = ProductBUS.ProductDetail(id),
                TenLoaiSanPham   = ProductBUS.GetTenLoaiSanPham(id),
                TenNhaCungCap    = ProductBUS.GetTenNhaCungCap(id),
                TenNhaSanXuat    = ProductBUS.GetTenNhaSanXuat(id)
            };

            return(View(info));
            //var sp = ProductBUS.ProductDetail(id);
            //return View(sp);
        }
        public AddProductForm(
            BindingSource productTypeBindingSource,
            BindingSource supplierBindingSource,
            BindingSource productBrandBindingSource
            )

        {
            InitializeComponent();
            selectedProductTypes = new ObservableListSource <ProductType>();
            selectedSuppliers    = new ObservableListSource <Supplier>();
            bus = new ProductBUS();
            productBrandBindingSource_All.DataSource = productBrandBindingSource.DataSource;
            productTypeBindingSource_All.DataSource  = productTypeBindingSource.DataSource;
            supplierBindingSource_All.DataSource     = supplierBindingSource.DataSource;
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ml"] != null)
                {
                    int type = 0;
                    int.TryParse(Request.QueryString["ml"].ToString(), out type);
                    List <SAN_PHAM_DTO> list = ProductBUS.GetProductsFollowType(type);
                    if (list.Count <= 0)
                    {
                        idh4.InnerHtml = "Chưa có sản phẩm nào!";
                    }
                    DataList1.DataSource = list;
                    DataList1.DataBind();
                    switch (type)
                    {
                    case 1:
                        lb.InnerHtml = "VẬT LIỆU THÔ";
                        break;

                    case 2:
                        lb.InnerHtml = "VẬT LIỆU HOÀN THIỆN";
                        break;

                    case 3:
                        lb.InnerHtml = "HỆ THỐNG ỐNG VÀ PHỤ KIỆN";
                        break;

                    case 4:
                        lb.InnerHtml = "VẬT LIỆU ĐẶT BIỆT";
                        break;

                    case 5:
                        lb.InnerHtml = "ĐỒ NỘI THẤT TRONG NHÀ";
                        break;

                    case 6:
                        lb.InnerHtml = "THIẾT BỊ NHÀ TẮM - VỆ SINH";
                        break;

                    case 7:
                        lb.InnerHtml = "THIẾT BỊ NHÀ BẾP";
                        break;
                    }
                }
            }
        }
Beispiel #9
0
 void DelProduct(int idProduct, string name, int idCat)
 {
     if (MessageBox.Show("Bạn đã chắc chắn muốn xóa " + name + " chưa?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         bool result = new ProductBUS().DelProduct(idProduct);
         if (result)
         {
             GetCatProToppingByIdCat(idCat);
             namePro = "";
             MessageBox.Show("Xóa thành công :3", "Thông báo");
         }
         else
         {
             MessageBox.Show("Xóa thất bại :(", "Thông báo");
         }
     }
 }
Beispiel #10
0
        public Manage()
        {
            InitializeComponent();
            sorter = new ListViewColumnSorter();
            lvCatalog.ListViewItemSorter = sorter;
            lvCombo.ListViewItemSorter   = sorter;
            lvProduct.ListViewItemSorter = sorter;
            lvBill.ListViewItemSorter    = sorter;

            accountBUS     = new AccountBUS();
            billBUS        = new BillBUS();
            billDetailBUS  = new BillDetailBUS();
            catalogBUS     = new CatalogBUS();
            comboBUS       = new ComboBUS();
            comboDetailBUS = new ComboDetailBUS();
            productBUS     = new ProductBUS();
        }
Beispiel #11
0
        private void FilterProduct()
        {
            if (cbLoaiThucUong.SelectedIndex >= 0 && cbxProductSizes.SelectedIndex >= 0)
            {
                if (cbLoaiThucUong.SelectedItem == null || cbxProductSizes.SelectedItem == null)
                {
                    return;
                }

                var typeProduct = cbLoaiThucUong.SelectedItem as TypeProductDTO;
                var typeId      = typeProduct.ID;

                var size   = cbxProductSizes.SelectedItem as ProductSize;
                var sizeId = size.Id;

                LoadProductListByTypeProductID(ProductBUS.GetListProductByIDTypeProduct(typeId, 1, sizeId));
            }
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List <SAN_PHAM_DTO> list = ProductBUS.SelectTopNewProducts();
                DataList1.DataSource = list;
                DataList1.DataBind();

                /*     string strProduct = "<table class='tbproduct'>";
                 *   int n = list.Count;
                 *   int m=Min(3,n);
                 *   strProduct += AddListProducts(0,list, m);
                 *   m = Min(6, n);
                 *   strProduct += AddListProducts(3,list, m);
                 *   m = Min(9, n);
                 *   strProduct += AddListProducts(6,list, m);
                 *   strProduct += "</table>";
                 *   divNewProduce.InnerHtml = strProduct;*/
                /*
                 *
                 *    <td class='produce'>
                 *        <asp:LinkButton ID='lbtProduce' runat='server'>
                 *            <img src='../../Content/images/bep-karador.jpg' />
                 *            <img src='../../Content/images/new.gif' />
                 *            <br />
                 *
                 *        </asp:LinkButton>
                 *            <label id='lbName' class='lbname' runat='server'>Bếp ga Karador</label><br />
                 *            <label id='lbSaleOff' runat='server'>Giảm giá : 0%</label><br />
                 *            <label class='label' id='lbPrice' runat='server'>Giá : 5000000 VNĐ/sp</label>
                 *
                 *          <asp:LinkButton ID='LinkButton3' runat='server'>
                 *            <img src='../../Content/images/xemchitiet_but.gif' />
                 *        </asp:LinkButton>
                 *
                 *    </td>
                 *
                 *        </asp:LinkButton>
                 *
                 *
                 *    </td>
                 */
            }
        }
Beispiel #13
0
        private void save_Click(object sender, EventArgs e)
        {
            ProductInfo product = new ProductInfo();

            product.ProductName = txtTen.Text;
            product.Price       = int.Parse(txtGia.Text);
            product.Image       = image;
            product.Quantity    = int.Parse(txtSoLuong.Text);
            product.UnitID      = int.Parse(cbxDonvi.SelectedValue.ToString());
            product.Description = txtMota.Text;
            product.ProductName = txtTen.Text;
            product.SupplierID  = int.Parse(cbxNhacungcap.SelectedValue.ToString());
            product.WarehouseID = int.Parse(cbxKho.SelectedValue.ToString());
            product.Code        = txtMa.Text;

            ProductBUS productBUS = new ProductBUS();

            productBUS.AddProduct(product);
        }
Beispiel #14
0
        private void frm_YeuCauGoiThucUong_Load(object sender, EventArgs e)
        {
            LoadProductSize();
            LoadProductListByTypeProductID(ProductBUS.GetListProductByIDTypeProduct(0, 1));

            cbLoaiThucUong.ContextMenu = new ContextMenu();
            timer1.Enabled             = true;
            btnThanhToan.Enabled       = false;
            btnTamTinh.Enabled         = false;

            lstBillNoPayment.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            lstBillNoPayment.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            lstProductCart.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            lstProductCart.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            lstProduct.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            lstProduct.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Beispiel #15
0
        private void LoadProducts()
        {
            ProductBUS            bus      = new ProductBUS();
            List <ProductDisplay> list     = new List <ProductDisplay>();
            List <ProductDTO>     products = bus.LoadAllProduct();

            for (int i = 0; i < products.Count(); i++)
            {
                list.Add(new ProductDisplay()
                {
                    id = products[i].ID, name = products[i].Name, inputprice = products[i].InputPrice, outputprice = products[i].OutputPrice
                });
            }
            listProduct.ItemsSource = list;

            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listProduct.ItemsSource);

            view.Filter = UserFilter;
        }
Beispiel #16
0
        private void btnImport_Clicked(object sender, RoutedEventArgs e)
        {
            if (txtAmount.Text.Count() == 0 || btnProduct.Content.ToString().Count() == 0 || btnSuplier.Content.ToString().Count() == 0)
            {
                lblNotice.Content    = "Please fill all information.";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }


            int  amount;
            bool isNumeric = Int32.TryParse(txtAmount.Text, out amount);

            if (!isNumeric)
            {
                lblNotice.Content    = "Amount isn't number!";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }



            ProductBUS bus    = new ProductBUS();
            ProductDTO result = bus.LoadOneProduct(Global.IDProduct);

            result.IvenNum = result.IvenNum + amount;
            bus.UpdateProduct(result);


            ImportDTO import = new ImportDTO();

            import.Product   = Int32.Parse(btnProduct.Content.ToString());
            import.Suplier   = Int32.Parse(btnSuplier.Content.ToString());
            import.Amount    = amount;
            import.Total     = amount * result.InputPrice;
            import.DateInput = lblDate.Content.ToString();

            ImportBUS importBUS = new ImportBUS();

            importBUS.AddNewImport(import);

            this.Close();
        }
Beispiel #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List <SAN_PHAM_DTO> list = ProductBUS.SelectModifyNewProducts();
                DataList1.DataSource = list;
                DataList1.DataBind();

                /*  string strProduct = "<table class='tbproduct'>";
                 * int n = list.Count;
                 * int m = Min(3, n);
                 * strProduct += AddListProducts(0, list, m);
                 * m = Min(6, n);
                 * strProduct += AddListProducts(3, list, m);
                 * m = Min(9, n);
                 * strProduct += AddListProducts(6, list, m);
                 * strProduct += "</table>";
                 * divNewProduce.InnerHtml = strProduct*/
            }
        }
        private void btnSave_Clicked(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Count() == 0 || txtInputPrice.Text.Count() == 0 || txtOutputPrice.Text.Count() == 0)
            {
                lblNotice.Content    = "Please fill all information.";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }


            int  temp;
            bool isNumeric = Int32.TryParse(txtInputPrice.Text, out temp);

            if (!isNumeric)
            {
                lblNotice.Content    = "Input price isn't number!";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }

            isNumeric = Int32.TryParse(txtOutputPrice.Text, out temp);
            if (!isNumeric)
            {
                lblNotice.Content    = "Output price isn't number!";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }

            ProductBUS bus    = new ProductBUS();
            ProductDTO result = new ProductDTO();

            result.ID          = ID;
            result.Name        = txtName.Text;
            result.IvenNum     = Int32.Parse(lblAmount.Content.ToString());
            result.InputPrice  = Int32.Parse(txtInputPrice.Text);
            result.OutputPrice = Int32.Parse(txtOutputPrice.Text);
            bus.UpdateProduct(result);
            this.Close();
        }
Beispiel #19
0
        //  private Button button;

        /*  public Button Button
         * {
         *    get {
         *        return (Button)FormView1.FindControl("Button1");
         *    }
         *
         * }
         */
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string masp = Request.QueryString["masp"];
                if (masp == null)
                {
                    masp = "VL001";
                }
                ma = masp;
                SAN_PHAM_DTO        sp   = ProductBUS.GetProductInfor(masp);
                List <SAN_PHAM_DTO> list = new List <SAN_PHAM_DTO>();
                list.Add(sp);
                FormView1.DataSource = list;
                FormView1.DataBind();
                DataList1.DataSource = ProductBUS.GetProductsSameType(sp.MaLoaiSanPham, sp.MaSanPham);
                DataList1.DataBind();

                /*  GridView1.DataSource = list;
                 * GridView1.DataBind();*/
            }
        }
Beispiel #20
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Product product = new Product()
            {
                id          = Int32.Parse(txtId.Text),
                name        = txtName.Text.ToString(),
                cateid      = Int32.Parse(txtCateId.Text),
                price       = Int32.Parse(txtPrice.Text),
                description = txtDesc.Text.ToString(),
                imagelink   = txtImageLink.Text.ToString()
            };

            if (ProductBUS.Insert(product))
            {
                MessageBox.Show("Success !");
            }
            else
            {
                MessageBox.Show("F**k You !");
            }
            dataGridView1.DataSource = ProductBUS.getAllProducts();
            this.clearText();
        }
Beispiel #21
0
 public Form1()
 {
     InitializeComponent();
     dataGridView1.DataSource = ProductBUS.getAllProducts();
 }
 public CreateProductForm()
 {
     _productBUS = new ProductBUS();
     InitializeComponent();
 }
Beispiel #23
0
 private void btnTimKiem_Click(object sender, EventArgs e)
 {
     LoadProductListByTypeProductID(ProductBUS.GeProductByName(txtTuKhoa.Text));
 }
Beispiel #24
0
 // Load datbase to view without change in category and brand
 private void onLoad()
 {
     productTBBindingSource.DataSource = ProductBUS.getAll();
     productBindingSource.DataSource   = new Product();
     dgvProduct.ClearSelection();
 }
Beispiel #25
0
 public ProductListForm()
 {
     _productBUS = new ProductBUS();
     InitializeComponent();
 }
    protected void txtProductID_TextChanged(object sender, EventArgs e)
    {
        int ProductID = 0;

        if (int.TryParse(txtProductID.Text, out ProductID) != false)
        {
            ProductID = int.Parse(txtProductID.Text);
            prBUS = new ProductBUS();
            ConnectionData.OpenMyConnection();
        }
        else
        {
            Visible(false);
            pnInfo.Visible = true;
            lblInfo.Text = "Bạn phải nhập mã sản phẩm là số !";
            return;
        }
        DataTable product = prBUS.GetByID(ProductID);
        if (product.Rows.Count > 0)
        {
            pnInfo.Visible = false;
            txtProductName.Text = product.Rows[0]["Title"].ToString();
            txtUnitPrice.Text = product.Rows[0]["UnitPrice"].ToString();
            txtQuantity.Text = "1";
           float total = int.Parse(txtQuantity.Text) * float.Parse(this.txtUnitPrice.Text);
           this.txtTotal.Text = total.ToString();
        }
        else
        {
            Visible(false);
            pnInfo.Visible = true;
            lblInfo.Text = "Không tồn tại mã sản phẩm này !";
            txtProductName.Text = "";
            txtUnitPrice.Text = "";
        }
        ConnectionData.CloseMyConnection();
    }
        private void LoadFinancePieChartData(DateTime DayFrom, DateTime DayTo)
        {
            //Luu id san pham va so luong san pham do ban trong hom nay
            List <KeyValue> listKey = new List <KeyValue>();


            ExportBUS        bus  = new ExportBUS();
            List <ExportDTO> list = bus.LoadAllExport(); //luu danh sach hoa don

            ProductBUS productBUS = new ProductBUS();


            for (int i = 0; i < list.Count(); i++)
            {
                //Kiem tra co nam trong pham vi bao cao hay khong
                DateTime soldDay = DateTime.Parse(list[i].DateOutput);
                if (soldDay < DayFrom || soldDay > DayTo)
                {
                    continue;
                }


                bool check = false;
                for (int j = 0; j < listKey.Count(); j++)
                {
                    //Xem ton tai trong list hay chua
                    if (listKey[j].key == list[i].Product)
                    {                      //Da ton tai
                        check = true;
                        int        income; //income of that bill
                        ProductDTO product = productBUS.LoadOneProduct(list[i].Product);
                        income            = list[i].Total - product.InputPrice * list[i].Amount;
                        listKey[j].value += income;
                        break;
                    }
                }

                //neu chua ton tai thi them vao
                if (check == false)
                {
                    int        income; //income of that bill
                    ProductDTO product = productBUS.LoadOneProduct(list[i].Product);
                    income = list[i].Total - product.InputPrice * list[i].Amount;
                    listKey.Add(new KeyValue()
                    {
                        key = list[i].Product, value = income
                    });
                }
            }


            var listStatistic = new List <KeyValuePair <string, int> >();

            for (int i = 0; i < listKey.Count(); i++)
            {
                ProductDTO product = productBUS.LoadOneProduct(listKey[i].key);
                listStatistic.Add(new KeyValuePair <string, int>(product.Name, listKey[i].value));
            }



            ((PieSeries)mcChart.Series[0]).ItemsSource = listStatistic;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int isLogIn;

            int.TryParse(Session["IsLogin"].ToString(), out isLogIn);
            if (isLogIn == 1)
            {
                string typeUser = Session["LoaiUser"].ToString();
                if (typeUser == "Manager")
                {
                    #region hiển thị thông tin sản phẩm
                    if (!IsPostBack)
                    {
                        //lấy mã sản phẩm
                        string masp = Request.QueryString["masp"];
                        if (masp != "")
                        {
                            SAN_PHAM_DTO sp = ProductBUS.LayThongTinSanPhamTheoMaSP(masp);


                            lbMaSP.Text = sp.MaSanPham;
                            //xử lý mã loại sp
                            //lbMaLSP.Text=sp.MaLoaiSanPham.ToString();
                            LOAISP_DTO lsp = ProductTypeBUS.LayLoaiSanPhamTheoMaLoaiSP(sp.MaLoaiSanPham);
                            lbMaLSP.Text = lsp.TenLoaiSanPham;

                            lbTenSP.Text     = sp.TenSanPham;
                            txtareMota.Value = sp.MoTaSanPham;

                            //xử lý hình ảnh
                            ImageSP.ImageUrl = sp.HinhAnh;

                            txtChatLuong.Text    = sp.ChatLuong;
                            txtGiaBan.Text       = sp.Gia.ToString();
                            txtSoLuong.Text      = sp.SoLuong.ToString();
                            txtDonVi.Text        = sp.DonViTinh;
                            lbSoLuongConLai.Text = sp.SoLuongConLai.ToString();
                            lbNgayDangSP.Text    = sp.NgayDangSanPham.ToString("dd/MM/yyyy");
                            lbNgaySuaDoi.Text    = sp.NgaySuaDoi.ToString("dd/MM/yyyy");

                            //xử lý tình trạng
                            radiobtnTinhTrang.SelectedValue = sp.TinhTrangSanPham;
                            if (radiobtnTinhTrang.SelectedValue == "0")
                            {
                                radiobtnTinhTrang.Items[0].Enabled = true;
                            }
                            else
                            {
                                radiobtnTinhTrang.Items[1].Enabled = true;
                            }

                            //không hiển thị ngày xóa

                            txtSoNguoiMua.Text = sp.SoNguoiMua.ToString();
                        }
                    }
                    #endregion
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
Beispiel #29
0
        protected void btnPayment_Click(object sender, EventArgs e)
        {
            string ma = rdvc.SelectedValue;

            string[] arr  = ma.Split(new char[] { ',' });
            int      madv = 0;

            int.TryParse(arr[0], out madv);
            int type = 0;

            int.TryParse(arr[1], out type);
            string bank = rdbank.SelectedValue;

            string[] bankarr = bank.Split(new char[] { '+' });
            string   bankid  = bankarr[0];
            string   stk     = bankarr[1];

            /* tao don hang , va xoa gio hang */
            if (Session["Cart"] != null)
            {
                List <GioHang> carts = (List <GioHang>)Session["Cart"];
                if (carts.Count > 0)
                {
                    DON_HANG_DTO dh = new DON_HANG_DTO();
                    dh.DiaChiNhan  = txtAddress.Text;
                    dh.DonViTienTe = carts[0].TienTe;
                    dh.NgayGiao    = DateTime.Now;
                    dh.UserName    = Session["User"].ToString();
                    dh.TongTien    = 0;
                    foreach (GioHang cart in carts)
                    {
                        dh.TongTien += (cart.DonGia * cart.SoLuong);
                    }
                    int madh = 0;
                    madh       = DonHangBUS.InsetOrder(dh);
                    dh.ChiTiet = new List <CHI_TIET_DON_HANG_DTO>();
                    foreach (GioHang cart in carts)
                    {
                        CHI_TIET_DON_HANG_DTO ct = new CHI_TIET_DON_HANG_DTO();
                        ct.donGia    = cart.DonGia;
                        ct.donViTinh = cart.DonViTinh;
                        ct.maDonHang = madh;
                        ct.maSanPham = cart.MaSanPham;
                        ct.soLuong   = cart.SoLuong;
                        try
                        {
                            DonHangBUS.InsertCTOrder(ct);
                        }
                        catch (Exception ex)
                        {
                            continue;
                        }
                    }
                    /* thanh toan */
                    SERVICE_BANK_DTO     svbank = ServiceBankBUS.LayServiceBankTheoMaBank(bankid);
                    NganHang.KhachHangWS proxy1 = new BIZ.NganHang.KhachHangWS();
                    string sid    = proxy1.Authenticate(svbank.UserName, svbank.PassWord);
                    int    result = proxy1.TransferMoney(sid, txtId.Text, bankid, svbank.Stk, svbank.MaBank, dh.TongTien, "VND");
                    if (result == 1)
                    {
                        /* dang ky van chuyen */
                        SERVICE_TRANS_DTO          svtran = ServiceTransBUS.GetServiceTransInfor(madv);
                        VanChuyen.FedexWebService1 proxy2 = new BIZ.VanChuyen.FedexWebService1();
                        sid = proxy2.Authenticate(svtran.UserName, svtran.PassWord);
                        string url = proxy2.TransportGoods(sid, madh.ToString(), carts.Count, DateTime.Now.AddDays(1), txtAddress.Text, type, svtran.BizAddress);
                        if (url.IndexOf(".aspx?") >= 0 || url.IndexOf("http://") >= 0 || url.IndexOf("https://") >= 0)
                        {
                            PACKAGEINFO_DTO pac = new PACKAGEINFO_DTO();
                            pac.URL            = url;
                            pac.MaServiceTrans = svtran.MaDV;
                            pac.PackageInfo    = madh.ToString();
                            try
                            {
                                DonHangBUS.InsertPackage(pac, madh);
                                foreach (GioHang cart in carts)
                                {
                                    //CHI_TIET_DON_HANG_DTO ct = new CHI_TIET_DON_HANG_DTO();

                                    try
                                    {
                                        ProductBUS.UpdateSLProduct(cart.MaSanPham, cart.SoLuong);
                                    }
                                    catch (Exception ex)
                                    {
                                        continue;
                                    }
                                }
                                Session["Cart"]    = null;
                                lbresult.ForeColor = Color.Green;
                                lbresult.Text      = "Quá trình mua đã thành công";
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                        else
                        {
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Đã thanh toán nhưng đặt vận chuyển thất bại";
                        }
                    }
                    else
                    {
                        switch (result)
                        {
                        case 2:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản chuyển không đủ tiền";
                            break;

                        case 3:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản chuyển không tồn tại";
                            break;

                        case 4:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản nhận không tồn tại";
                            break;

                        case 5:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Mã ngân hàng chuyển tiền/Mã ngân hàng nhận tiền không tồn tại ";
                            break;

                        case 6:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Lỗi khác";
                            break;
                        }
                    }
                }
            }
        }
Beispiel #30
0
 public Page <SanPham> Get(int id, int page = 1)
 {
     return(ProductBUS.ListProductType(page, 4, id));
 }
Beispiel #31
0
        // GET: Admin/Product
        public ActionResult Index()
        {
            var listProduct = ProductBUS.List();

            return(View(listProduct));
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        bool status = false;
        InitBus();
        string err = ValidateInput();
        //Thêm khách hàng
        if (err == "")
        {
            try
            {
                if (ctBUS.GetByEmail(GetCustomerDTO().Email).Rows.Count > 0)
                {
                    CustomerID = int.Parse(ctBUS.GetByEmail(GetCustomerDTO().Email).Rows[0]["Id"].ToString());
                    ctBUS.tblCustomer_Update(GetCustomerDTO());
                }
                else
                {
                    CustomerID = ctBUS.tblCustomer_insert(GetCustomerDTO());
                }
                int GroupID = int.Parse(this.drlGroupMail.SelectedValue);
                DetailGroupDTO dgDTO = new DetailGroupDTO() { CustomerID = CustomerID, GroupID = GroupID };
                //Thêm vào nhóm mail
                if (dgBUS.GetByID(GroupID, CustomerID).Rows.Count == 0)
                {
                    dgBUS.tblDetailGroup_insert(dgDTO);
                }
                //Thêm vào hóa đơn
                if (oBUS.tblOrder_GetByID(GetOrderDTO().OrderID).Rows.Count > 0 || hdfUpdate.Value!="")
                {
                    status = GetOrderDTO().Status;
                    oBUS.tblOrder_updateStatus(GetOrderDTO().OrderID, status);
                }
                else
                {
                    oBUS.tblOrder_insert(GetOrderDTO());
                }
                // Thêm vào chi tiết hóa đơn
                DataTable tblProduct = (DataTable)Session["orderList"];
                if (tblProduct.Rows.Count > 0)
                {
                    OrderDatailDTO odDTO = new OrderDatailDTO();
                    for (int i = 0; i < tblProduct.Rows.Count; i++)
                    {
                        //Thêm từng sản phẩm vào chi tiết đơn hàng
                        odDTO.ProductID = int.Parse(tblProduct.Rows[i]["ProductID"].ToString());
                        odDTO.OrderID = txtOrderID.Text;
                        odDTO.ProductName = tblProduct.Rows[i]["ProductName"].ToString();
                        odDTO.DeliveryCode = tblProduct.Rows[i]["DeliveryCode"].ToString();
                        odDTO.UnitPrice = float.Parse(tblProduct.Rows[i]["UnitPrice"].ToString());
                        odDTO.Quantity = int.Parse(tblProduct.Rows[i]["Quantity"].ToString());
                        odDTO.Total = odDTO.Quantity * odDTO.UnitPrice;
                        odDTO.Note = tblProduct.Rows[i]["Note"].ToString();
                        odDTO.Size = "M";
                        int CateGoryID;
                        if (odBUS.tblOrderDetail_GetByID(txtOrderID.Text, odDTO.ProductID).Rows.Count > 0)
                        {
                            odBUS.tblOrderDetail_update(odDTO);
                        }
                        else
                        {
                            odBUS.tblOrderDetail_insert(odDTO);
                        }

                        if (status == true)
                        {
                            prBUS = new ProductBUS();
                            //Lấy nhóm của sản phẩm
                            CateGoryID = int.Parse(prBUS.GetByID(odDTO.ProductID).Rows[0]["Category"].ToString());
                            countBUS = new CountBuyBUS();
                            if (countBUS.GetByID(CustomerID, CateGoryID).Rows.Count > 0)
                            {
                                //Cập nhật số lần mua của khách hàng này theo nhóm sản phẩm
                                countBUS.tblCountBuy_UpdateCountBuy(CustomerID, CateGoryID);
                            }
                            else
                            {
                                //Thêm vào đếm lần mua theo nhóm
                                countBUS.tblCountBuy_insert(CustomerID, CateGoryID, 1);
                            }
                        }

                    }
                    //Cập nhật số lần mua cho khách hàng
                    if (status == true)
                    {
                        ctBUS = new CustomerBUS();
                        ctBUS.tblCustomer_UpdateCountBuy(CustomerID);
                    }
                    //Load lại thông tin khách hàng
                    Visible(false);
                    pnSuccess.Visible = true;
                    lblSuccess.Text = "Cập nhật thành công một đơn hàng";
                    LoadDefautlValue();
                    Session["orderList"] = null;
                    //Tạo mã hóa đơn tự động
                    AutoCreateID();
                }
            }
            catch (Exception ex)
            {
                Visible(false);
                pnError.Visible = true;
                lblError.Text = "Lỗi xảy ra trong quá trình nhập:" + ex.Message;
            }
        }
        else
        {
            Visible(false);
            pnError.Visible = true;
            lblError.Text = err;
        }
    }