Exemplo n.º 1
0
        public static bool Delete(NhatKyNguyenLieu data, User user)
        {
            try
            {
                if (data != null)
                {
                    NhatKyNguyenLieu objDb = GetById(data.Id);

                    if (objDb != null)
                    {
                        objDb.DeleteFlag = true;
                        dbContext.SubmitChanges();

                        return true;
                    }
                }
            }
            catch
            {

            }

            CreateSQlConnection();

            return false;
        }
Exemplo n.º 2
0
 public static bool Update(NhatKyNguyenLieu data, User user)
 {
     return NhatKyNguyenLieuDao.Update(data, user);
 }
Exemplo n.º 3
0
 public static bool Insert(NhatKyNguyenLieu data, User user)
 {
     return NhatKyNguyenLieuDao.Insert(data, user);
 }
Exemplo n.º 4
0
        private void InsertData()
        {
            foreach (DataGridViewRow row in dgvThongTin.Rows)
            {
                DTO.NhatKyNguyenLieu data = new DTO.NhatKyNguyenLieu();

                data.IdNguyenLieu = ConvertUtil.ConvertToInt(row.Cells[colIdNguyenLieu.Name].Value);
                data.Date = dtpFilter.Value;
                data.TonDau = ConvertUtil.ConvertToDouble(row.Cells[colTonDau.Name].Value);
                data.Nhap = ConvertUtil.ConvertToDouble(row.Cells[colNhap.Name].Value);
                data.Huy = ConvertUtil.ConvertToDouble(row.Cells[colHuy.Name].Value);
                data.TonCuoi = ConvertUtil.ConvertToDouble(row.Cells[colTonCuoi.Name].Value);
                data.SuDung = ConvertUtil.ConvertToDouble(row.Cells[colSuDung.Name].Value);
                data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString();

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

                        return;
                    }
                }
            }

            MessageBox.Show(string.Format(Constant.MESSAGE_INSERT_SUCCESS, "Nhật ký"), Constant.CAPTION_INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            RefreshData(string.Empty, true, dtpFilter.Value);
        }
Exemplo n.º 5
0
        private ListView GetListView(string text, bool? isActive, DateTime date)
        {
            ListView lv = new ListView();

            if (NhatKyNguyenLieuBus.GetCount(text, isActive, date) > 0 && HoaDonBus.GetByDate(date) != null)
            {
                List<DTO.NhatKyNguyenLieu> listNLLyThuyet = new List<DTO.NhatKyNguyenLieu>();
                List<DTO.NhatKyNguyenLieu> listNLThucTe = NhatKyNguyenLieuBus.GetList(string.Empty, true, date,
                    string.Empty, string.Empty, 0, 0);
                List<DTO.HoaDon> listHoaDon = HoaDonBus.GetList(string.Empty, 0, 0, date, string.Empty, string.Empty, 0, 0);

                foreach (DTO.NhatKyNguyenLieu data in listNLThucTe)
                {
                    DTO.NhatKyNguyenLieu dataNKNL = new DTO.NhatKyNguyenLieu();

                    dataNKNL.IdNguyenLieu = data.IdNguyenLieu;
                    dataNKNL.SuDung = 0;

                    listNLLyThuyet.Add(dataNKNL);
                }

                foreach (DTO.HoaDon hoaDon in listHoaDon)
                {
                    List<DTO.HoaDonDetail> listHoaDonDetail = HoaDonDetailBus.GetListByIdHoaDon(hoaDon.Id);

                    foreach (DTO.HoaDonDetail data in listHoaDonDetail)
                    {
                        List<DTO.DinhLuong> listDL = DinhLuongBus.GetListByIdSP(data.IdSanPham);

                        foreach (DTO.DinhLuong dataDL in listDL)
                        {
                            listNLLyThuyet.Where(p => p.IdNguyenLieu == dataDL.IdNguyenLieu).FirstOrDefault().SuDung += dataDL.SoLuong * data.SoLuong;
                        }
                    }
                }

                for (int i = 0; i < lvThongTin.Columns.Count; i++)
                {
                    lv.Columns.Add((ColumnHeader)lvThongTin.Columns[i].Clone());
                }

                for (int i = 0; i < listNLThucTe.Count; i++)
                {
                    double lyThuyet = listNLLyThuyet[i].SuDung;
                    double thucTe = listNLThucTe[i].SuDung;
                    double chenhLech = thucTe - lyThuyet;
                    double percentChenhLech = ((thucTe / lyThuyet) - 1) * 100;

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = (lv.Items.Count + 1).ToString();
                    lvi.SubItems.Add(listNLThucTe[i].NguyenLieu.Ten);
                    lvi.SubItems.Add(listNLThucTe[i].NguyenLieu.DonViTinh);
                    lvi.SubItems.Add(lyThuyet.ToString());
                    lvi.SubItems.Add(thucTe.ToString());
                    lvi.SubItems.Add(chenhLech.ToString());

                    if (double.IsNaN(percentChenhLech))
                    {
                        lvi.SubItems.Add(Constant.NaN);
                    }
                    else if (double.IsInfinity(percentChenhLech))
                    {
                        lvi.SubItems.Add(Constant.INFINITY);
                    }
                    else
                    {
                        lvi.SubItems.Add(percentChenhLech.ToString(Constant.DEFAULT_FORMAT_PERCENT) + Constant.SYMBOL_PERCENT);
                    }

                    lv.Items.Add(lvi);
                }
            }

            return lv;
        }
Exemplo n.º 6
0
 partial void DeleteNhatKyNguyenLieu(NhatKyNguyenLieu instance);
Exemplo n.º 7
0
 partial void UpdateNhatKyNguyenLieu(NhatKyNguyenLieu instance);
Exemplo n.º 8
0
 partial void InsertNhatKyNguyenLieu(NhatKyNguyenLieu instance);
Exemplo n.º 9
0
		private void detach_NhatKyNguyenLieus(NhatKyNguyenLieu entity)
		{
			this.SendPropertyChanging();
			entity.NguyenLieu = null;
		}
Exemplo n.º 10
0
        public static bool Update(NhatKyNguyenLieu data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();

                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Exemplo n.º 11
0
        public static bool Insert(NhatKyNguyenLieu data, User user)
        {
            try
            {
                dbContext.NhatKyNguyenLieus.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }