private void bunifuImageButton3_Click(object sender, EventArgs e) { if (check()) { QLNTEntities1 db = new QLNTEntities1(); var id = dNS.FirstOrDefault(temp => temp.Value == comboBoxTenCay.Text).Key; foreach (var item in listCtTH) { if (item.MaNS == id) { item.SanLuongThuHoach = Convert.ToDouble(textSanLuongThuHoach.Text); item.SanLuongThietHai = Convert.ToDouble(textSanLuongThietHai.Text); break; } } MessageBox.Show("Sửa thành công"); var result = from c in listCtTH join ns in db.NongSan on c.MaNS equals ns.MaNS join p in db.Cay on ns.MaLoaiCay equals p.MaLoaiCay select new { MaNS = c.MaNS, TenCay = p.TenCay, SanLuongThuHoach = c.SanLuongThuHoach, SanLuongThietHai = c.SanLuongThietHai }; dataGrid.DataSource = result.ToList(); setTextNull(); show_button_add(); hide_button_luu(); comboBoxTenCay.Enabled = true; } }
private void bunifuImageButton2_Click(object sender, EventArgs e) { if (check()) { QLNTEntities1 db = new QLNTEntities1(); ChiTiet_TH temp = new ChiTiet_TH(); //var luucbb = comboBoxTenCay.Text; int maNS = dNS.FirstOrDefault(c => c.Value == comboBoxTenCay.Text).Key; luucb.Add(comboBoxTenCay.Text); temp.MaNS = maNS; temp.SanLuongThuHoach = Convert.ToDouble(textSanLuongThuHoach.Text); temp.SanLuongThietHai = Convert.ToDouble(textSanLuongThietHai.Text); listCtTH.Add(temp); var result = from c in listCtTH join ns in db.NongSan on c.MaNS equals ns.MaNS join p in db.Cay on ns.MaLoaiCay equals p.MaLoaiCay select new { MaNS = c.MaNS, TenCay = p.TenCay, SanLuongThuHoach = c.SanLuongThuHoach, SanLuongThietHai = c.SanLuongThietHai }; dataGrid.DataSource = result.ToList(); index_row = index_row + 1; setTextNull(); comboBoxTenCay.DataSource = null; comboBoxTenCay.Items.Clear(); foreach (var item in dNS) { comboBoxTenCay.Items.Add(item.Value); foreach (var str in luucb) { if (item.Value == str) { comboBoxTenCay.Items.Remove(item.Value); } } } } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { int id = 0; using (QLNTEntities1 db = new QLNTEntities1()) { BangThuHoach b = new BangThuHoach(); b.NgayThuHoach = DateTime.Now; b.MaNV = dNV.SingleOrDefault(c => c.Value == comboBoxTenNV.Text).Key; db.BangThuHoach.Add(b); db.SaveChanges(); db.Entry(b).GetDatabaseValues(); id = b.MaBang; } /// using (QLNTEntities1 db = new QLNTEntities1()) { foreach (var item in listCtTH) { item.MaBang = id; db.ChiTiet_TH.Add(item); } db.SaveChanges(); } this.Close(); bus.View(dataGrid); }
private void loadChart() { QLNTEntities1 db = new QLNTEntities1(); var result = db.ThongKeSanLuong(Convert.ToInt16(comboThang.Text), Convert.ToInt32(comboBoxNam.Text)); int i = 0; //chart2.Series["SLThuHoach"].IsValueShownAsLabel = false; chart2.Series["SLThuHoach"].IsValueShownAsLabel = true; chart1.ChartAreas[0].AxisX.Title = "Nông sản"; chart1.ChartAreas[0].AxisY.Title = "Kg"; foreach (var item in result) { ///Bar chart chart1.Series["SLThuHoach"].Points.AddXY(item.TenNS, item.SLThuHoach); chart1.Series["SLThietHai"].Points.AddXY(item.TenNS, item.SLThietHai); chart1.Series["SLThuHoach"].Points[i].Label = item.SLThuHoach.ToString(); chart1.Series["SLThietHai"].Points[i].Label = item.SLThietHai.ToString(); //Pie chart chart2.Series["SLThuHoach"].Points.AddXY(item.TenNS, item.SLThuHoach); i++; } if (i == 0) { MessageBox.Show(string.Format("Không có dữ liệu tháng {0} năm {1}", comboThang.Text, comboBoxNam.Text)); chart1.Visible = false; chart2.Visible = false; } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { if (check()) { var temp = comboboxDoDoc.Text; Dictionary <string, string> d; using (QLNTEntities1 db = new QLNTEntities1()) { d = ( from z in db.DoDoc select new { z.MaDoc, z.MucDoDoc } ).ToDictionary(z => z.MaDoc, z => z.MucDoDoc); } var kq = d.Keys.ToString(); foreach (var k in d) { if (k.Value.ToString() == temp.ToString()) { kq = k.Key.ToString(); break; } } o = new ThuocBaoVeTV() { MaThuoc = this.id, TenThuoc = textTenThuoc.Text, Dang = comboboxDang.Text, SoLuong = Convert.ToInt32(textSoLuong.Text), ThoiGianCachLy = Convert.ToInt32(textThoiGianCachLy.Text), NoiSX = textNoiSX.Text, CongDung = textCongDung.Text, NgaySX = DatepickerSX.Value.Date, HanSD = DatepickerHSD.Value.Date, MaDoc = kq }; bus.Edit(o); MessageBox.Show("Sửa thành công"); Dialog_close(); } }
public Dictionary <int, string> View() { using (QLNTEntities1 db = new QLNTEntities1()) { //var result = from c in db.PhanBons select new { TenPB=c.TenPB, Loai=c} ; Dictionary <int, string> d = db.LoaiKH.Select(t => new { t.MaLoai, t.TenLoai }).ToDictionary(t => t.MaLoai, t => t.TenLoai);; return(d); } }
private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { string id; if (dataGrid.Columns[e.ColumnIndex].Name == "Sua") { if (index_row == 0) { MessageBox.Show("Dữ liệu trống không thể sửa!"); return; } hide_button_add(); show_button_luu(); MessageBox.Show("Nhập lại nội dung muốn sửa"); id = dataGrid.Rows[e.RowIndex].Cells["MaNS"].Value.ToString(); foreach (var item in listCtTH) { if (item.MaNS.ToString() == id) { comboBoxTenCay.Text = dNS.SingleOrDefault(tem => tem.Key.ToString() == id).Value; textSanLuongThuHoach.Text = item.SanLuongThuHoach.ToString(); textSanLuongThietHai.Text = item.SanLuongThietHai.ToString(); } } comboBoxTenCay.Enabled = false; } QLNTEntities1 db = new QLNTEntities1(); if (dataGrid.Columns[e.ColumnIndex].Name == "Xoa") { if (index_row == 0) { MessageBox.Show("Dữ liệu trống không thể xóa!"); return; } id = dataGrid.Rows[e.RowIndex].Cells["MaNS"].Value.ToString(); var re = listCtTH.Where(p => p.MaNS == Convert.ToInt32(id)).SingleOrDefault(); listCtTH.Remove(re); index_row--; var tencay = dNS.Where(p => p.Key == Convert.ToInt32(id)).SingleOrDefault().Value; comboBoxTenCay.Items.Add(tencay); var result = from c in listCtTH join ns in db.NongSan on c.MaNS equals ns.MaNS join p in db.Cay on ns.MaLoaiCay equals p.MaLoaiCay where c.MaNS != Convert.ToInt32(id) select new { MaNS = c.MaNS, TenCay = p.TenCay, SanLuongThuHoach = c.SanLuongThuHoach, SanLuongThietHai = c.SanLuongThietHai }; dataGrid.DataSource = result.ToList(); } }
private void loadChart() { QLNTEntities1 db = new QLNTEntities1(); var result = db.ThongKeDoanhThuTheoNam(Convert.ToInt32(comboBoxNam.Text)); var chart = chart1.ChartAreas[0]; chart.AxisX.Minimum = 1; chart.AxisX.Maximum = 12; chart.AxisX.Title = "Tháng"; chart.AxisY.Title = "Triệu"; foreach (var item in result) { chart1.Series["DoanhThu"].Points.AddXY(item.Thang, (item.DoanhThu * 1.0) / 1000000); } }
public Diablog_viewbangth(string id) { InitializeComponent(); border(); int ma = Convert.ToInt32(id); QLNTEntities1 db = new QLNTEntities1(); string la = db.BangThuHoach.Where(c => c.MaBang == ma).SingleOrDefault().NgayThuHoach.ToString(); label3.Text = la; var result = from c in db.ChiTiet_TH join ns in db.NongSan on c.MaNS equals ns.MaNS join p in db.Cay on ns.MaLoaiCay equals p.MaLoaiCay where c.MaBang == ma select new { TenCay = p.TenCay, SanLuongThuHoach = c.SanLuongThuHoach, SanLuongThietHai = c.SanLuongThietHai, MaBang = c.MaBang }; dataGrid.DataSource = result.ToList(); //button_luu.Enabled = false; }
public Diablog_NS(string id) { InitializeComponent(); border(); NongSanDB db = new NongSanDB(); ds = busCay.getAllNameTree(); // MessageBox.Show(ds.Count.ToString()); comboBoxLoaiCay.DataSource = ds.Values.ToList(); // load noi dung de sua thong tin #region gắn giá trị this.id = Convert.ToInt32(id); o = db.getNongSan(id); textThoiGianBaoQuan.Text = o.ThoiGianBaoQuan.ToString(); textSanLuongTonKho.Text = o.SanLuongTonKho.ToString(); textDonGia.Text = o.DonGia.ToString(); Dictionary <int, string> d; using (QLNTEntities1 db1 = new QLNTEntities1()) { d = ( from z in db1.Cay select new { z.MaLoaiCay, z.TenCay } ).ToDictionary(z => z.MaLoaiCay, z => z.TenCay); } var kq = d.Values.ToString(); foreach (var k in d) { if (k.Key.ToString() == o.MaLoaiCay.ToString()) { kq = k.Value.ToString(); break; } } comboBoxLoaiCay.Text = kq; #endregion // An button add button_add.Enabled = false; button_add.Visible = false; //Hien button luu button_luu.Visible = true; //button_luu.Enabled = false; }
private void button_add_Click(object sender, EventArgs e) { if (check()) { var temp = comboboxDoDoc.Text; Dictionary <string, string> d; using (QLNTEntities1 db = new QLNTEntities1()) { d = ( from z in db.DoDoc select new { z.MaDoc, z.MucDoDoc } ).ToDictionary(z => z.MaDoc, z => z.MucDoDoc); } var kq = d.Keys.ToString(); foreach (var k in d) { if (k.Value.ToString() == temp.ToString()) { kq = k.Key.ToString(); break; } } o = new ThuocBaoVeTV() { TenThuoc = textTenThuoc.Text, Dang = comboboxDang.Text, SoLuong = Convert.ToInt32(textSoLuong.Text), ThoiGianCachLy = Convert.ToInt32(textThoiGianCachLy.Text), NoiSX = textNoiSX.Text, CongDung = textCongDung.Text, NgaySX = DatepickerSX.Value.Date, HanSD = DatepickerHSD.Value.Date, MaDoc = kq }; bus.Add(o); MessageBox.Show("Thêm thành công"); Dialog_close(); } #region kt //string t="Tên phân bón : {0} \n Loại: {1} \n Ngày sx: {2} \n hạn sử dụng: {3}"; //string msg = string.Format(t,o.TenPB,o.Loai,o.NgaySX.ToString("dd//MM/yyyy"), o.HanSD.ToString("dd//MM/yyyy")); //MessageBox.Show(msg); //DatepickerSX.Value.ToString("dd/MM/yyyy") //MessageBox.Show(textTenPB.Text+" " + comboBoxLoai.Text ); //MessageBox.Show("thành công"); #endregion }
private void button_luu_Click(object sender, EventArgs e) { if (check()) { var temp = comboBoxLoaiCay.Text; /*var re = from c in db.NongSan * join d in db.Cay on c.MaLoaiCay equals d.MaLoaiCay * where String.Compare(temp, d.TenCay.ToString(), true); * select new ()*/ Dictionary <int, string> d; using (QLNTEntities1 db = new QLNTEntities1()) { d = ( from z in db.Cay select new { z.MaLoaiCay, z.TenCay } ).ToDictionary(z => z.MaLoaiCay, z => z.TenCay); } var key = d.Values; var kq = d.Keys.ToString(); foreach (var k in d) { if (k.Value.ToString() == temp.ToString()) { kq = k.Key.ToString(); break; } } //MessageBox.Show(kq); o = new NongSan() { MaNS = this.id, ThoiGianBaoQuan = Convert.ToInt32(textThoiGianBaoQuan.Text), SanLuongTonKho = Convert.ToDouble(textSanLuongTonKho.Text), DonGia = Convert.ToDouble(textDonGia.Text), MaLoaiCay = Convert.ToInt32(kq) }; bus.Edit(o); MessageBox.Show("Sửa thành công"); Dialog_close(); } }
public Diablog_TBV() { InitializeComponent(); border(); List <string> l = new List <string>() { "Dung dịch", "Hạt", "Bột", "Viên", "Nhũ dầu", "Huyền phù", "Thuốc phun bột" }; comboboxDang.DataSource = l; Dictionary <string, string> d; using (QLNTEntities1 db = new QLNTEntities1()) { d = ( from c in db.DoDoc select new { c.MaDoc, c.MucDoDoc } ).ToDictionary(c => c.MaDoc, c => c.MucDoDoc); } comboboxDoDoc.DataSource = d.Values.ToList(); }
public Diablog_BangTH(string id) { InitializeComponent(); border(); BangThuHoachDB db = new BangThuHoachDB(); // load noi dung de sua thong tin Dictionary <int, string> d; using (QLNTEntities1 db1 = new QLNTEntities1()) { d = ( from c in db1.Cay select new { c.MaLoaiCay, c.TenCay } ).ToDictionary(c => c.MaLoaiCay, c => c.TenCay); } comboBoxTenCay.DataSource = d.Values.ToList(); using (QLNTEntities1 db1 = new QLNTEntities1()) { d = ( from c in db1.NhanVien select new { c.MaNV, c.TenNV } ).ToDictionary(c => c.MaNV, c => c.TenNV); } comboBoxTenNV.DataSource = d.Values.ToList(); #region gắn giá trị this.id = Convert.ToInt32(id); o = db.GetBangThuHoach(id); //textSanLuongThuHoach.Text = o..ToString(); // DatepickerNgayThuHoach.Value.ToString("dd/MM/yyyy"); #endregion //Hien button luu button_luu.Visible = true; //button_luu.Enabled = false; }
public Diablog_BangTH() { InitializeComponent(); border(); hide_button_luu(); using (QLNTEntities1 db = new QLNTEntities1()) { dNS = ( from ns in db.NongSan join c in db.Cay on ns.MaLoaiCay equals c.MaLoaiCay select new { ns.MaNS, c.TenCay } ).ToDictionary(ns => ns.MaNS, c => c.TenCay); } comboBoxTenCay.DataSource = dNS.Values.ToList(); using (QLNTEntities1 db = new QLNTEntities1()) { dNV = ( from c in db.NhanVien select new { c.MaNV, c.TenNV } ).ToDictionary(c => c.MaNV, c => c.TenNV); } comboBoxTenNV.DataSource = dNV.Values.ToList(); }
private void button_add_Click(object sender, EventArgs e) { if (check()) { var temp = comboBoxLoaiCay.Text; Dictionary <int, string> d; using (QLNTEntities1 db = new QLNTEntities1()) { d = ( from z in db.Cay select new { z.MaLoaiCay, z.TenCay } ).ToDictionary(z => z.MaLoaiCay, z => z.TenCay); } var key = d.Values; var kq = d.Keys.ToString(); foreach (var k in d) { if (k.Value.ToString() == temp.ToString()) { kq = k.Key.ToString(); break; } } o = new NongSan() { ThoiGianBaoQuan = Convert.ToInt32(textThoiGianBaoQuan.Text), SanLuongTonKho = Convert.ToDouble(textSanLuongTonKho.Text), DonGia = Convert.ToDouble(textDonGia.Text), MaLoaiCay = Convert.ToInt32(kq) }; bus.Add(o); MessageBox.Show("Thêm thành công"); Dialog_close(); //} #region kt //string t="Tên phân bón : {0} \n Loại: {1} \n Ngày sx: {2} \n hạn sử dụng: {3}"; //string msg = string.Format(t,o.TenPB,o.Loai,o.NgaySX.ToString("dd//MM/yyyy"), o.HanSD.ToString("dd//MM/yyyy")); //MessageBox.Show(msg); //DatepickerSX.Value.ToString("dd/MM/yyyy") //MessageBox.Show(textTenPB.Text+" " + comboBoxLoai.Text ); //MessageBox.Show("thành công"); #endregion } /*private void bunifuFlatButton1_Click(object sender, EventArgs e) * { * * if (check()) * { * o = new NongSan() { MaNS = this.id, ThoiGianBaoQuan = Convert.ToInt32(textThoiGianBaoQuan.Text), SanLuongTonKho = Convert.ToDouble(textSanLuongTonKho), DonGia = Convert.ToDouble(textDonGia.Text), BaoQuan = textBaoQuan.Text }; * bus.Edit(o); * * Dialog_close(); * } * } * * private void Diablog_NS_Load(object sender, EventArgs e) * { * ds = busCay.getAllNameTree(); * // MessageBox.Show(ds.Count.ToString()); * comboBoxLoaiCay.DataSource = ds.Values.ToList(); * }*/ }
public Diablog_TBV(string id) { InitializeComponent(); border(); ThuocBaoVeTVDB db = new ThuocBaoVeTVDB(); List <string> l = new List <string>() { "Dung dịch", "Hạt", "Bột", "Viên", "Nhũ dầu", "Huyền phù", "Thuốc phun bột" }; comboboxDang.DataSource = l; Dictionary <string, string> dic; using (QLNTEntities1 db1 = new QLNTEntities1()) { dic = ( from c in db1.DoDoc select new { c.MaDoc, c.MucDoDoc } ).ToDictionary(c => c.MaDoc, c => c.MucDoDoc); } comboboxDoDoc.DataSource = dic.Values.ToList(); #region gắn giá trị this.id = Convert.ToInt32(id); o = db.GetThuocBaoVeTV(id); textTenThuoc.Text = o.TenThuoc; textThoiGianCachLy.Text = o.ThoiGianCachLy.ToString(); textNoiSX.Text = o.NoiSX; comboboxDang.Text = o.Dang; textSoLuong.Text = o.SoLuong.ToString(); textCongDung.Text = o.CongDung; DatepickerSX.Value = o.NgaySX; DatepickerSX.Value.ToString("dd/MM/yyyy"); DatepickerHSD.Value = o.HanSD; DatepickerHSD.Value.ToString("dd/MM/yyyy"); var temp = o.MaDoc; Dictionary <string, string> d; using (QLNTEntities1 db1 = new QLNTEntities1()) { d = ( from z in db1.DoDoc select new { z.MaDoc, z.MucDoDoc } ).ToDictionary(z => z.MaDoc, z => z.MucDoDoc); } var kq = d.Values.ToString(); foreach (var k in d) { if (k.Key.ToString() == temp.ToString()) { kq = k.Value.ToString(); break; } } comboboxDoDoc.Text = kq; #endregion // An button add button_add.Enabled = false; button_add.Visible = false; //Hien button luu button_luu.Visible = true; //button_luu.Enabled = false; }