Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public static bool Update(KhuyenMai data)
 {
     return KhuyenMaiDao.Update(data);
 }
Ejemplo n.º 3
0
 public static bool Insert(KhuyenMai data)
 {
     return KhuyenMaiDao.Insert(data);
 }
Ejemplo n.º 4
0
 public static bool Delete(KhuyenMai data)
 {
     return KhuyenMaiDao.Delete(data);
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 partial void DeleteKhuyenMai(KhuyenMai instance);
Ejemplo n.º 7
0
 partial void UpdateKhuyenMai(KhuyenMai instance);
Ejemplo n.º 8
0
 partial void InsertKhuyenMai(KhuyenMai instance);
Ejemplo n.º 9
0
		private void detach_KhuyenMais1(KhuyenMai entity)
		{
			this.SendPropertyChanging();
			entity.SanPham1 = null;
		}
Ejemplo n.º 10
0
		private void attach_KhuyenMais(KhuyenMai entity)
		{
			this.SendPropertyChanging();
			entity.SanPham = this;
		}
Ejemplo n.º 11
0
        public static bool Update(KhuyenMai data)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 12
0
        public static bool Insert(KhuyenMai data)
        {
            try
            {
                dbContext.KhuyenMais.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }