예제 #1
0
        public static bool Delete(DinhLuong data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.DinhLuongs.DeleteOnSubmit(data);
                    dbContext.SubmitChanges();

                    return true;
                }
            }
            catch
            {
                //return false;
            }

            CreateSQlConnection();

            return false;
        }
예제 #2
0
 public static bool Update(DinhLuong data, User user)
 {
     return DinhLuongDao.Update(data, user);
 }
예제 #3
0
 public static bool Insert(DinhLuong data, User user)
 {
     return DinhLuongDao.Insert(data, user);
 }
예제 #4
0
 public static bool Delete(DinhLuong data, User user)
 {
     return DinhLuongDao.Delete(data, user);
 }
예제 #5
0
 partial void DeleteDinhLuong(DinhLuong instance);
예제 #6
0
 partial void UpdateDinhLuong(DinhLuong instance);
예제 #7
0
 partial void InsertDinhLuong(DinhLuong instance);
예제 #8
0
		private void detach_DinhLuongs(DinhLuong entity)
		{
			this.SendPropertyChanging();
			entity.SanPham = null;
		}
예제 #9
0
		private void detach_DinhLuongs(DinhLuong entity)
		{
			this.SendPropertyChanging();
			entity.NguyenLieu = null;
		}
예제 #10
0
        private void UpdateDinhLuong()
        {
            if (!DeleteDataHoaDonDetail())
            {
                return;
            }

            for (int i = 0; i < dgvThongTin.RowCount; i++)
            {
                if (dgvThongTin[colId.Name, i].Value != null && !string.IsNullOrEmpty(dgvThongTin[colId.Name, i].Value.ToString()))
                {
                    DTO.DinhLuong dataDL = DinhLuongBus.GetById(ConvertUtil.ConvertToInt(dgvThongTin[colId.Name, i].Value));

                    dataDL.IdNguyenLieu = ConvertUtil.ConvertToInt(dgvThongTin[colIdNL.Name, i].Value);
                    dataDL.SoLuong = ConvertUtil.ConvertToDouble(dgvThongTin[colUocLuong.Name, i].Value);
                    dataDL.GhiChu = dgvThongTin[colGhiChu.Name, i].Value == null ? string.Empty : dgvThongTin[colGhiChu.Name, i].Value.ToString();

                    if (!DinhLuongBus.Update(dataDL, FormMain.user))
                    {
                        if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            this.Dispose();
                        }

                        return;
                    }
                }
                else
                {
                    DTO.DinhLuong dataDL = new DTO.DinhLuong();

                    dataDL.IdSanPham = data.Id;
                    dataDL.IdNguyenLieu = ConvertUtil.ConvertToInt(dgvThongTin[colIdNL.Name, i].Value);
                    dataDL.SoLuong = ConvertUtil.ConvertToDouble(dgvThongTin[colUocLuong.Name, i].Value);
                    dataDL.GhiChu = dgvThongTin[colGhiChu.Name, i].Value == null ? string.Empty : dgvThongTin[colGhiChu.Name, i].Value.ToString();

                    if (!DinhLuongBus.Insert(dataDL, FormMain.user))
                    {
                        if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            this.Dispose();
                        }

                        return;
                    }
                }
            }

            if (MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Sản phẩm " + data.MaSanPham) + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                this.Dispose();
            }
        }
예제 #11
0
        public static bool Update(DinhLuong data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
예제 #12
0
        public static bool Insert(DinhLuong data, User user)
        {
            try
            {
                dbContext.DinhLuongs.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }