Beispiel #1
0
        public void CapNhatCTHD(CTHD ct)
        {
            DAO_CTHD dao = new DAO_CTHD();

            dao.Open();
            dao.CapNhatCTHD(ct);
            dao.Close();
        }
        protected void gvCTHD_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int         mahd   = int.Parse(Session["MaHoaDon"].ToString());
            GridViewRow row    = gvCTHD.Rows[e.RowIndex];
            BUS_SanPham busSp  = new BUS_SanPham();
            int         masp   = int.Parse(row.Cells[1].Text);
            int         masize = 0;
            string      s      = row.Cells[3].Text;

            switch (row.Cells[3].Text)
            {
            case "s":
                masize = 0;
                break;

            case "m":
                masize = 1;
                break;

            case "l":
                masize = 2;
                break;

            case "xl ":
                masize = 3;
                break;

            case "xxl":
                masize = 4;
                break;
            }
            TextBox txtSoLuong = row.FindControl("txtSoLuong") as TextBox;
            string  soluong    = txtSoLuong.Text.Trim();

            CTHD ct = new CTHD();

            ct.MAHD    = mahd;
            ct.MASP    = masp;
            ct.MASIZE  = masize;
            ct.SOLUONG = int.Parse(soluong);

            BUS_CTHD bus = new BUS_CTHD();

            bus.CapNhatCTHD(ct);



            gvCTHD.EditIndex = -1;
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();

            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.PageIndex  = int.Parse(Session["cthdPage"].ToString());
            gvCTHD.DataBind();
        }
Beispiel #3
0
        protected void btnXacNhan_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (DateTime.Now.CompareTo(DateTime.Parse(txtNgayGiao.Text.Trim())) > 0)
                {
                    lblNgayGiaoHang.Text = "Ngày giao hàng nhỏ hơn ngày hiện tại !";
                    return;
                }
                if (Session["Username"] != null && Session["GioHang"] != null)
                {
                    string        uname = (string)Session["Username"];
                    BUS_KhachHang busKH = new BUS_KhachHang();


                    int    MaKH         = busKH.LayMaKH(uname);
                    string ngaylaphd    = DateTime.Now.ToShortDateString();
                    string ngaygiaohang = txtNgayGiao.Text.Trim();
                    string dc           = txtDCNhan.Text.Trim();

                    // them hoa don
                    BUS_HoaDon busHD = new BUS_HoaDon();
                    HoaDon     hd    = new HoaDon();
                    hd.MAHD           = int.Parse(DateTime.Now.Millisecond.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString());
                    hd.NGAYLAPHD      = ngaylaphd;
                    hd.NGAYGIAOHANG   = ngaygiaohang;
                    hd.MAKH           = MaKH;
                    hd.DIACHIGIAOHANG = dc;
                    busHD.ThemHD(hd);
                    //them chi tiet hoa don
                    BUS_CTHD  busCTHD   = new BUS_CTHD();
                    ArrayList giohang   = (ArrayList)Session["GioHang"];
                    ArrayList chitietHD = new ArrayList();
                    foreach (SanPham sp in giohang)
                    {
                        CTHD cthd = new CTHD();
                        cthd.MAHD    = hd.MAHD;
                        cthd.MASP    = sp.MaSP;
                        cthd.MASIZE  = sp.MASIZE;
                        cthd.SOLUONG = sp.SoLuong;
                        cthd.DONGIA  = sp.GiaBan;
                        busCTHD.ThemCTHD(cthd);
                        chitietHD.Add(cthd);
                    }
                    Session["chitietHD"] = chitietHD;
                    Session["GioHang"]   = null;
                    Response.Redirect("thanhcong.htm");
                }
            }
        }
Beispiel #4
0
        public void CapNhatCTHD(CTHD cthd)
        {
            DAO_CTHD dao = new DAO_CTHD();

            dao.Open();
            string     qry = "CapNhatSoLuong";
            SqlCommand cmd = new SqlCommand(qry, dao.cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MaHD", SqlDbType.Int).Value    = cthd.MAHD;
            cmd.Parameters.Add("@MaSP", SqlDbType.Int).Value    = cthd.MASP;
            cmd.Parameters.Add("@MaSize", SqlDbType.Int).Value  = cthd.MASIZE;
            cmd.Parameters.Add("@SoLuong", SqlDbType.Int).Value = cthd.SOLUONG;
            cmd.Parameters.Add("@DonGia", SqlDbType.Int).Value  = cthd.DONGIA;
            cmd.Parameters.Add("@flag", SqlDbType.Int).Value    = 1;
            cmd.ExecuteNonQuery();
            dao.Close();
            cmd.Dispose();
        }
Beispiel #5
0
        public void ThemCTHD(CTHD cthd)
        {
            DAO_CTHD daoCTHD = new DAO_CTHD();

            daoCTHD.ThemCTHD(cthd);
        }