コード例 #1
0
ファイル: KhuyenMaiDao.cs プロジェクト: vuchannguyen/lg-py
        public static bool Delete(KhuyenMai data)
        {
            try
            {
                if (data != null)
                {
                    KhuyenMai objDb = GetById(data.Id);

                    if (objDb != null)
                    {
                        dbContext.KhuyenMais.DeleteOnSubmit(objDb);

                        return true;
                    }
                }
            }
            catch
            {

            }

            CreateSQlConnection();

            return false;
        }
コード例 #2
0
ファイル: KhuyenMaiBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Update(KhuyenMai data)
 {
     return KhuyenMaiDao.Update(data);
 }
コード例 #3
0
ファイル: KhuyenMaiBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Insert(KhuyenMai data)
 {
     return KhuyenMaiDao.Insert(data);
 }
コード例 #4
0
ファイル: KhuyenMaiBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Delete(KhuyenMai data)
 {
     return KhuyenMaiDao.Delete(data);
 }
コード例 #5
0
ファイル: UcKhuyenMai.cs プロジェクト: vuchannguyen/lg-py
        private void UpdateData()
        {
            foreach (DataGridViewRow row in dgvThongTin.Rows)
            {
                if (ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value) != 0 &&
                    ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value) != 0)
                {
                    if (row.Cells[colId.Name].Value != null && !string.IsNullOrEmpty(row.Cells[colId.Name].Value.ToString()))
                    {
                        DTO.KhuyenMai data = KhuyenMaiBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colId.Name].Value));
                        data.SoLuongSanPham = row.Cells[colSoLuongSanPham.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value);
                        data.SanPham1 = SanPhamBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colSanPhamKhuyenMai.Name].Value));
                        data.SoLuongSanPhamKhuyenMai = row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value);
                        data.DonViLamTron = row.Cells[colDonViLamTron.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToDouble(row.Cells[colDonViLamTron.Name].Value);
                        data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString();

                        if (KhuyenMaiBus.Update(data))
                        {
                            //this.Dispose();
                        }
                        else
                        {
                            if (MessageBox.Show(Constant.MESSAGE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                            {
                                //this.Dispose();

                                return;
                            }
                        }
                    }
                    else
                    {
                        DTO.KhuyenMai data = new DTO.KhuyenMai();
                        data.IdSanPham = ConvertUtil.ConvertToInt(row.Cells[colIdSanPham.Name].Value);
                        data.SoLuongSanPham = row.Cells[colSoLuongSanPham.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value);
                        data.IdSanPhamKhuyenMai = ConvertUtil.ConvertToInt(row.Cells[colSanPhamKhuyenMai.Name].Value);
                        data.SoLuongSanPhamKhuyenMai = row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value);
                        data.DonViLamTron = row.Cells[colDonViLamTron.Name].Value == null ? 0 :
                            ConvertUtil.ConvertToDouble(row.Cells[colDonViLamTron.Name].Value);
                        data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString();

                        if (KhuyenMaiBus.Insert(data))
                        {
                            //this.Dispose();
                        }
                        else
                        {
                            if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                            {
                                //this.Dispose();

                                return;
                            }
                        }
                    }
                }
            }

            //pbSua.Enabled = false;
            //pbSua.Image = Image.FromFile(ConstantResource.CHUC_NANG_ICON_EDIT_DISABLE);

            MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Khuyến mãi"), Constant.CAPTION_CONFIRMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #6
0
 partial void DeleteKhuyenMai(KhuyenMai instance);
コード例 #7
0
 partial void UpdateKhuyenMai(KhuyenMai instance);
コード例 #8
0
 partial void InsertKhuyenMai(KhuyenMai instance);
コード例 #9
0
		private void detach_KhuyenMais1(KhuyenMai entity)
		{
			this.SendPropertyChanging();
			entity.SanPham1 = null;
		}
コード例 #10
0
		private void attach_KhuyenMais(KhuyenMai entity)
		{
			this.SendPropertyChanging();
			entity.SanPham = this;
		}
コード例 #11
0
ファイル: KhuyenMaiDao.cs プロジェクト: vuchannguyen/lg-py
        public static bool Update(KhuyenMai data)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
コード例 #12
0
ファイル: KhuyenMaiDao.cs プロジェクト: vuchannguyen/lg-py
        public static bool Insert(KhuyenMai data)
        {
            try
            {
                dbContext.KhuyenMais.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }