Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        public void Edit(ThuocBaoVeTV o)
        {
            ThuocBaoVeTVDB db = new ThuocBaoVeTVDB();

            db.Edit(o);
        }
Beispiel #5
0
        public void Add(ThuocBaoVeTV o)
        {
            ThuocBaoVeTVDB db = new ThuocBaoVeTVDB();

            db.Add(o);
        }