public static void CreateCoupon(COUPON_DTO couDTO) { try { CouponDAO.CreateCoupon(couDTO); } catch (Exception ex) { throw ex; } }
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.UpdateCoupon(couDTO); ; lbResultInfo.Text = "Đã cập nhật thành công"; } catch (Exception ex) { throw new Exception(ex.Message); } }
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(); } }
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(); } }
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(); } }
public static void UpdateCoupon(COUPON_DTO cp) { try { CouponDAO.UpdateCoupon(cp); } catch (Exception e) { throw e; } }