Beispiel #1
0
 public static List<ExceptionPOS> Load(ExceptionPOS obj)
 {
     using(var model= new SGCoopSTEntities())
     {
         var list = from l in model.ExceptionPOS where l.MaDotKhuyenMai == obj.MaDotKhuyenMai select l;
         return list.ToList();
     }
 }
        void set_object(string GuidCT, int STT)
        {
            //Khuyen Mai POS
            objKM.TenDotKhuyenMai = txtTenDotKhuyenMai.Text;
            objKM.MaDotKhuyenMai = STT.ToString("0000000000");
            objKM.HinhThucKM = int.Parse(cboKhuyenMai.SelectedValue.ToString().Trim());
            objKM.MaNVTao = CurrentUser.MaNV;
            objKM.TuNgay = dateTuNgay.Value;
            objKM.DenNgay = dateDenNgay.Value;
            objKM.STT = STT;
            objKM.GhiChu = txtGhiChu.Text;
            objKM.DaApDung = chkDaApDung.Checked;
            objKM.DaThucHien = chkDaThucHien.Checked;
            objKM.IsExept = chkLoaiTruSKU.Checked;
            objKM.IsCombo = chkCombo.Checked;

            //KM Sieu Thi

            //CTKhuyen Mai POS
            objCT.MaDotKhuyenMai = STT.ToString("0000000000");
            objCT.CTKhuyenMaiID = GuidCT;
            objCT.MaLoaiKhuyenMai = cboKhuyenMai.SelectedValue.ToString();
            objCT.STT = STT;
            if (txtDKCongDiem.Enabled == true && txtDiemThuongGioiHan.Enabled == true)
                objCT.DieuKien = txtDKCongDiem.Text;
            else
                objCT.DieuKien = "0";

            if (txtDiemThuongGioiHan.Enabled == true)
                objCT.DiemThuongGioiHan = decimal.Parse(txtDiemThuongGioiHan.Text);
            else
                objCT.DiemThuongGioiHan = decimal.Parse("0");
            objCT.GiaTriTongHoaDon = decimal.Parse(txtGiaTriHoaDon.Text);
            objCT.GhiChu = txtGhiChu.Text;

            //Dieu kien khuyen mai POS
            for (int i = 0; i < dgvDieuKienKM.Rows.Count; i++)
            {
                objDK = new DieuKienKhuyenMaiPOS();
                DataGridViewRow dr = dgvDieuKienKM.Rows[i];
                if (dr.Cells["GiaTri"].Value == null
                    || dr.Cells["TongGiaTri"].Value == null
                    || dr.Cells["TongSoLuong"].Value == null
                    || dr.Cells["DiemThuong"].Value==null
                    || dr.Cells["DiemThuongGioiHan"].Value==null)
                {
                    break;
                }
                objDK.CTKhuyenMaiID = GuidCT;
                objDK.GiaTri = dr.Cells["GiaTri"].Value.ToString();
                objDK.TongGiaTri = decimal.Parse(dr.Cells["TongGiaTri"].Value.ToString().Replace(".", ""));
                objDK.TongSoLuong = decimal.Parse(dr.Cells["TongSoLuong"].Value.ToString());
                objDK.DiemThuong = decimal.Parse(dr.Cells["DiemThuong"].Value.ToString());
                objDK.DiemThuongGioiHan = decimal.Parse(dr.Cells["DiemThuongGioiHan"].Value.ToString());
                lstDK.Add(objDK);
            }

            //Exception POS
            if (chkLoaiTruSKU.Checked == true)
            {
                for (int i = 0; i < dgvExPOS.Rows.Count; i++)
                {
                    objEX = new ExceptionPOS();
                    DataGridViewRow dr = dgvExPOS.Rows[i];
                    if (dr.Cells["SKULoaiTru"].Value == null)
                        break;
                    objEX.MaDotKhuyenMai = STT.ToString("0000000000");
                    objEX.SKULoaiTru = dr.Cells["SKULoaiTru"].Value.ToString();

                    lstEX.Add(objEX);
                }
            }
        }
        void load_data_update()
        {
            txtTenDotKhuyenMai.Text = objKM.TenDotKhuyenMai;
            cboKhuyenMai.SelectedItem = objKM.HinhThucKM.ToString().Trim();
            chkCombo.Checked = bool.Parse(objKM.IsCombo.ToString());
            chkLoaiTruSKU.Checked = bool.Parse(objKM.IsExept.ToString());
            dateTuNgay.Value = objKM.TuNgay;
            dateDenNgay.Value = objKM.DenNgay;
            chkDaApDung.Checked = objKM.DaApDung;
            chkDaThucHien.Checked = bool.Parse(objKM.DaThucHien.ToString());

            //*******load CTKhuyenMaiPOS************************************//
            objCT = new CTKhuyenMaiPOS();
            objCT.MaDotKhuyenMai = objKM.MaDotKhuyenMai;
            objCT = CTLCTKhuyenMaiPOS.load(objCT);

            txtDKCongDiem.Text = objCT.DieuKien;
            txtDiemThuongGioiHan.Text = objCT.DiemThuongGioiHan.ToString();
            txtGiaTriHoaDon.Text = format_value(objCT.GiaTriTongHoaDon.ToString().Replace(".00", ""));
            txtGhiChu.Text = objCT.GhiChu;

            //******load DieuKienKhuyenMai POS*****************************//
            objDK = new DieuKienKhuyenMaiPOS();
            objDK.CTKhuyenMaiID = objCT.CTKhuyenMaiID;

            lstDK = new List<DieuKienKhuyenMaiPOS>();
            lstDK = CTLDieuKienKhuyenMaiPOS.Load(objDK);
            if(lstDK.Count>0)
            {
                dgvDieuKienKM.AutoGenerateColumns = false;
                dgvDieuKienKM.DataSource = lstDK;
            }

            //*****load ExceptionPOS**************************************//
            if(objKM.IsExept==true)
            {
                objEX = new ExceptionPOS();
                objEX.MaDotKhuyenMai = objKM.MaDotKhuyenMai;
                lstEX = new List<ExceptionPOS>();
                lstEX = CTLExceptionPOS.Load(objEX);
                if(lstEX.Count>0)
                {
                    dgvExPOS.AutoGenerateColumns = false;
                    dgvExPOS.DataSource = lstEX;
                }
            }
        }