예제 #1
0
        public static void UpdateCoupon(COUPON_DTO cp)
        {
            helper.connect();
            string sqlCommand        = "sp_UpdateCoupon1";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@macp", cp.MaCoupon));
            list.Add(new SqlParameter("@start", cp.ThoiGianBD));
            list.Add(new SqlParameter("@end", cp.ThoiGianKT));
            list.Add(new SqlParameter("@slspmin", cp.SoLuongSanPhamMin));
            list.Add(new SqlParameter("@giasgiam", cp.GiaSauGiam));
            list.Add(new SqlParameter("@dksd", cp.DieuKienSuDung));
            list.Add(new SqlParameter("@giagoc", cp.GiaGoc));
            list.Add(new SqlParameter("@slcpmin", cp.SoLuongCouponMin));
            try
            {
                helper.executeNonQueryProcedure(sqlCommand, list);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                helper.disconnect();
            }
        }
예제 #2
0
        public static void CreateCoupon(COUPON_DTO couDTO)
        {
            helper.connect();
            string sqlCommand      = "sp_TaoCoupon";
            List <SqlParameter> ds = new List <SqlParameter>();

            ds.Add(new SqlParameter("@maCoupon", couDTO.MaCoupon));
            ds.Add(new SqlParameter("@maSanPham", couDTO.MaSanPham));
            ds.Add(new SqlParameter("@giaSeGiam", couDTO.GiaSauGiam));
            ds.Add(new SqlParameter("@thoiGianBatDau", couDTO.ThoiGianBD));
            ds.Add(new SqlParameter("@thoiGianKetThuc", couDTO.ThoiGianKT));
            ds.Add(new SqlParameter("@soLuongSanPhamMin", couDTO.SoLuongSanPhamMin));
            ds.Add(new SqlParameter("@tinhTrangCoupon", couDTO.TinhTrangCoupon));
            ds.Add(new SqlParameter("@dieuKienSuDung", couDTO.DieuKienSuDung));
            ds.Add(new SqlParameter("@giaGoc", couDTO.GiaGoc));
            ds.Add(new SqlParameter("@donViTienTe", couDTO.DonViTienTe));
            ds.Add(new SqlParameter("@soLuongCouponMinGiamGia", couDTO.SoLuongCouponMin));
            try
            {
                helper.executeNonQueryProcedure(sqlCommand, ds);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                helper.disconnect();
            }
        }
예제 #3
0
 public static void CreateCoupon(COUPON_DTO couDTO)
 {
     try
     {
         CouponDAO.CreateCoupon(couDTO);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 public static void UpdateCoupon(COUPON_DTO cp)
 {
     try
     {
         CouponDAO.UpdateCoupon(cp);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #5
0
        protected void bttDangSP_Click(object sender, EventArgs e)
        {
            if (DateTimePicker1.getDate() == "" && DateTimePicker2.getDate() == "")
            {
                lbResultInfo.Text = "Chưa điền ngày";
                return;
            }
            DateTime batdau;
            DateTime ketthuc;

            if (!DateTime.TryParse(DateTimePicker1.getDate(), out batdau))
            {
                lbResultInfo.Text = "Trường ngày bắt đầu không đúng dịnh dạng ngày";
                return;
            }
            if (!DateTime.TryParse(DateTimePicker2.getDate(), out ketthuc))
            {
                lbResultInfo.Text = "Trường ngày kết thúc không đúng dịnh dạng ngày";
                return;
            }
            COUPON_DTO couDTO = new COUPON_DTO();

            couDTO.MaCoupon          = txtMaCP.Text;
            couDTO.MaSanPham         = ddlTenSP.SelectedValue.ToString();
            couDTO.GiaSauGiam        = float.Parse(txtGiaSauKhiGiam.Text);
            couDTO.ThoiGianBD        = batdau;
            couDTO.ThoiGianKT        = ketthuc;
            couDTO.SoLuongSanPhamMin = int.Parse(txtSLSPmin.Text);
            couDTO.TinhTrangCoupon   = "1";
            couDTO.DieuKienSuDung    = txtRreaDKSU.Value.ToString();
            couDTO.GiaGoc            = float.Parse(txtGiaGoc.Text);
            couDTO.DonViTienTe       = ddlDVTienTe.Text;
            couDTO.SoLuongCouponMin  = int.Parse(txtSLCPMinGiamGia.Text);
            try
            {
                CouponBUS.CreateCoupon(couDTO);
                lbResultInfo.Text = "Đã tạo thành công";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #6
0
        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" && Request.QueryString["macp"] != "")
                {
                    if (!IsPostBack)
                    {
                        string     macp = Request.QueryString["macp"];
                        COUPON_DTO cp   = CouponBUS.GetCouponInfor1(macp);
                        txtGiaGoc.Text         = cp.GiaGoc.ToString();
                        txtGiaSauKhiGiam.Text  = cp.GiaSauGiam.ToString();
                        txtMaCP.Text           = cp.MaCoupon;
                        txtRreaDKSU.Value      = cp.DieuKienSuDung;
                        txtSLCPMinGiamGia.Text = cp.SoLuongCouponMin.ToString();
                        txtSLSPmin.Text        = cp.SoLuongSanPhamMin.ToString();
                        DateTimePicker1.setDate(cp.ThoiGianBD.ToShortDateString());
                        DateTimePicker2.setDate(cp.ThoiGianKT.ToShortDateString());
                        TextBox1.Text = cp.TenSanPham;

                        /*
                         * List<Coupon> list = CouponBUS.GetCouponInfor(macp);
                         * txtGiaGoc.Text = list[0].GiaHangKhiChuaGiam.ToString();
                         * txtGiaSauKhiGiam.Text = list[0].GiaHangSauKhiGiam.ToString();
                         * txtMaCP.Text = list[0].MaCoupon;
                         * txtRreaDKSU.Value = list[0].DieuKienSuDung;
                         * txtSLCPMinGiamGia.Text=list[0].s*/
                    }
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
예제 #7
0
        public static COUPON_DTO GetCouponInfor1(string macp)
        {
            helper.connect();
            string sqlCommand = "sp_SelectCouponInfor1";
            // string sqlCommand1 = "sp_CountOrderCoupon";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@macp", macp));

            try
            {
                COUPON_DTO cp    = new COUPON_DTO();
                DataTable  table = helper.executeQueryDataTableProcedure(sqlCommand, list);
                if (table != null && table.Rows.Count > 0)
                {
                    DataRow row = table.Rows[0];
                    cp.MaCoupon          = row["MACP"].ToString();
                    cp.MaSanPham         = row["MASP"].ToString();
                    cp.GiaSauGiam        = float.Parse(row["GIASGIAM"].ToString());
                    cp.GiaGoc            = float.Parse(row["GIAGOC"].ToString());
                    cp.DieuKienSuDung    = row["DIEUKIENSD"].ToString();;
                    cp.DonViTienTe       = row["DVTIENTE"].ToString();;
                    cp.SoLuongCouponMin  = int.Parse(row["SLCPMINGIAMGIA"].ToString());
                    cp.SoLuongSanPhamMin = int.Parse(row["SLSPMIN"].ToString());
                    cp.ThoiGianBD        = DateTime.Parse(row["THOIGIANBD"].ToString());
                    cp.ThoiGianKT        = DateTime.Parse(row["THOIGIANKT"].ToString());
                    cp.TenSanPham        = row["TENSP"].ToString();
                }
                return(cp);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                helper.disconnect();
            }
        }