Пример #1
0
        private void guna2TextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (txtSearch.Text == "")
            {
                loadDL();
            }
            using (CUAHANGTIENLOI db = new CUAHANGTIENLOI())
            {
                List <DGVHANGHOA_Result> ds_hanghoa = db.DGVHANGHOA().Where(p => RemoveUnicode(p.TENHANG.ToLower()).Contains(RemoveUnicode(txtSearch.Text.ToLower()))).ToList();
                DataTable dt = new DataTable();
                dt.Columns.Add("mahang");
                dt.Columns.Add("tenhang");
                dt.Columns.Add("hsd");
                dt.Columns.Add("donvitinh");
                dt.Columns.Add("soluong");
                dt.Columns.Add("loaihang");
                dt.Columns.Add("hinh");
                dt.Columns.Add("giaban");
                foreach (DGVHANGHOA_Result item in ds_hanghoa)
                {
                    DateTime hsd = (DateTime)item.HSD;
                    dt.Rows.Add(item.MAHANG, item.TENHANG, hsd.ToString("yyyy-MM-dd"), item.DONVITINH, item.SOLUONG, item.TENLOAI, item.Hinh, item.GIABAN);
                }

                dgvHangHoa.DataSource = dt;
            }
        }
Пример #2
0
        void loadDL()
        {
            using (CUAHANGTIENLOI db = new CUAHANGTIENLOI())
            {
                cbLoaiSP.DataSource    = db.LOAISPs.ToList();
                cbLoaiSP.DisplayMember = "TENLOAI";
                cbLoaiSP.ValueMember   = "MALOAI";
                List <DGVHANGHOA_Result> ds_hanghoa = db.DGVHANGHOA().ToList();
                DataTable dt = new DataTable();
                dt.Columns.Add("mahang");
                dt.Columns.Add("tenhang");
                dt.Columns.Add("hsd");
                dt.Columns.Add("donvitinh");
                dt.Columns.Add("soluong");
                dt.Columns.Add("loaihang");
                dt.Columns.Add("hinh");
                dt.Columns.Add("giaban");
                foreach (DGVHANGHOA_Result item in ds_hanghoa)
                {
                    DateTime hsd = (DateTime)item.HSD;
                    dt.Rows.Add(item.MAHANG, item.TENHANG, hsd.ToString("yyyy-MM-dd"), item.DONVITINH, item.SOLUONG, item.TENLOAI, item.Hinh, item.GIABAN);
                }

                dgvHangHoa.DataSource = dt;
            }
        }
Пример #3
0
 private void dgvHangHoa_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     txtMaHang.Text  = dgvHangHoa.CurrentRow.Cells["mahang"].Value.ToString();
     txtTenhang.Text = dgvHangHoa.CurrentRow.Cells["tenhang"].Value.ToString();
     txtSL.Text      = dgvHangHoa.CurrentRow.Cells["soluong"].Value.ToString();
     txtHSD.Text     = dgvHangHoa.CurrentRow.Cells["hsd"].Value.ToString();
     txtGiaBan.Text  = dgvHangHoa.CurrentRow.Cells["giaban"].Value.ToString();
     txtDVT.Text     = dgvHangHoa.CurrentRow.Cells["donvitinh"].Value.ToString();
     cbLoaiSP.Text   = dgvHangHoa.CurrentRow.Cells["loaihang"].Value.ToString();
     using (CUAHANGTIENLOI db = new CUAHANGTIENLOI())
     {
         DGVHANGHOA_Result s = db.DGVHANGHOA().Where(p => p.MAHANG == int.Parse(txtMaHang.Text)).FirstOrDefault();
         if (s == null || s.Hinh == null)
         {
             picSP.Image = null;
         }
         else
         {
             MemoryStream stream = new MemoryStream(s.Hinh.ToArray());
             Image        im     = Image.FromStream(stream);
             if (im == null)
             {
                 return;
             }
             else
             {
                 picSP.Image = im;
             }
         }
     }
 }