private List<CTBenhNhanSnapShot> CloneSnapShot()
        {
            List<CTBenhNhanSnapShot> listSnapShot = new List<CTBenhNhanSnapShot>();
            for (int i = 0; i < gridView_SnapShot.DataRowCount; i++)
            {
                CTBenhNhanSnapShot snapshot = new CTBenhNhanSnapShot();
                //FileStream fs = new FileStream("Image", FileMode.Create, FileAccess.Write);
                //fs.Write(rawData, 0, fileSize);

                Binary imageBytes = (Binary)(gridView_SnapShot.GetRowCellValue(i, "URL"));
                snapshot.URL = imageBytes;
                snapshot.ID = int.Parse(gridView_SnapShot.GetRowCellValue(i, "ID").ToString());
                listSnapShot.Add(snapshot);
            }
            return listSnapShot;
        }
        public List<CTBenhNhanSnapShot> GetInfCTBenhNhanSnapShot()
        {
            List<CTBenhNhanSnapShot> listSnapShot = new List<CTBenhNhanSnapShot>();
            for (int i = 0; i < gridView_SnapShot.DataRowCount; i++)
            {
                CTBenhNhanSnapShot snapshot = new CTBenhNhanSnapShot();
                //FileStream fs = new FileStream("Image", FileMode.Create, FileAccess.Write);
                //fs.Write(rawData, 0, fileSize);

                Binary imageBytes = (Binary)(gridView_SnapShot.GetRowCellValue(i, "URL"));
                snapshot.URL = imageBytes;
                snapshot.IDCTBenhNhan = lblCTBenhNhan.Text;
                listSnapShot.Add(snapshot);
            }
            return listSnapShot;
        }
        private void btnBrowse_Click(object sender, System.EventArgs e)
        {
            openFileDialog1.Title = "Open File";
            openFileDialog1.Multiselect = true;
            openFileDialog1.Filter = "JPG,JPEG|*.jpg|PNG|*png";
            openFileDialog1.FileName = "";

            try
            {
                openFileDialog1.InitialDirectory = "C:\\";
            }
            catch
            {
                // skip it
            }
            //Cach2
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Random rnd = new Random();
                List<CTBenhNhanSnapShot> listSnap = CloneSnapShot();
                //if (txtFileName.Text != string.Empty)
                //{
                foreach (String filename in @openFileDialog1.FileNames)
                {
                    int id = rnd.Next(5200);
                    CTBenhNhanSnapShot snapshot = new CTBenhNhanSnapShot();
                    FileStream FS = new FileStream(@filename, FileMode.Open, FileAccess.Read);
                    byte[] img = new byte[FS.Length];
                    FS.Read(img, 0, Convert.ToInt32(FS.Length));
                    snapshot.URL = img;
                    snapshot.ID = id;
                    //id = id++;
                    listSnap.Add(snapshot);
                }
                grid_SnapShot.DataSource = listSnap;
                //UploadFile(txtFileName.Text);
                //ImportData();
                //}
                //else
                //    MessageBox.Show("Chọn file upload.", "Chưa có file");
                ////ThanhCong
                //List<sp_GetDSTraThuongNPPTrongThangResult> list = qlNPP.GetDSTraThuongNPPTrongThang(Thang, Nam, IDKhuVuc);
                //if (list.Count > 0 && list != null)
                //{
                //    AddItemCallback(list);
                //    this.Close();
                //}
            }
            //Cach1
            //openFileDialog1.ShowDialog();

            //if (openFileDialog1.FileName == "")
            //    return;
            //else
            //    txtFileName.Text = openFileDialog1.FileName;
        }
Пример #4
0
 public bool InsertCTBenhNhanSnapShot(CTBenhNhanSnapShot CTBenhNhanSnapShot)
 {
     DataClassesDataContext data = new DataClassesDataContext(Connection);
     data.CTBenhNhanSnapShots.InsertOnSubmit(CTBenhNhanSnapShot);
     try
     {
         data.SubmitChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
Пример #5
0
 partial void DeleteCTBenhNhanSnapShot(CTBenhNhanSnapShot instance);
Пример #6
0
 partial void UpdateCTBenhNhanSnapShot(CTBenhNhanSnapShot instance);
Пример #7
0
 partial void InsertCTBenhNhanSnapShot(CTBenhNhanSnapShot instance);
Пример #8
0
 private void btnImport_Click(object sender, System.EventArgs e)
 {
     Random rnd = new Random();
     List<CTBenhNhanSnapShot> listSnap = CloneSnapShot();
     if (txtFileName.Text != string.Empty)
     {
         CTBenhNhanSnapShot snapshot = new CTBenhNhanSnapShot();
         foreach (String filename in @openFileDialog1.FileNames)
         {
             int id = rnd.Next(5200);
             FileStream FS = new FileStream(filename, FileMode.Open, FileAccess.Read);
             byte[] img = new byte[FS.Length];
             FS.Read(img, 0, Convert.ToInt32(FS.Length));
             snapshot.URL = img;
             snapshot.ID = id;
             listSnap.Add(snapshot);
         }
         grid_SnapShot.DataSource = listSnap;
         //UploadFile(txtFileName.Text);
         //ImportData();
     }
     else
         MessageBox.Show("Chọn file upload.", "Chưa có file");
     ////ThanhCong
     //List<sp_GetDSTraThuongNPPTrongThangResult> list = qlNPP.GetDSTraThuongNPPTrongThang(Thang, Nam, IDKhuVuc);
     //if (list.Count > 0 && list != null)
     //{
     //    AddItemCallback(list);
     //    this.Close();
     //}
 }