Example #1
0
        /// <returns></returns>
        private ArrayList LoadLabelByID()
        {
            ArrayList    l  = new ArrayList();
            CTDBEntities ct = new CTDBEntities();

            foreach (tbLabel t in ct.tbLabel.Where <tbLabel>(c => (c.slice_id == sliceID)))
            {
                l.Add(t);
            }
            return(l);
        }
Example #2
0
        private void bsmAdd_Click(object sender, EventArgs e)
        {
            var s = new tbSpecimen();

            setDBValue(s);
            CTDBEntities ct = new CTDBEntities();

            ct.tbSpecimen.Add(s);
            ct.SaveChanges();   //将修改保存到数据库中
            refreshdata(dataGridView1.RowCount);
        }
Example #3
0
        /// <summary>更新数据库</summary>
        void refreshdb()
        {
            lbNote.Text = "更新数据库";
            CTDBEntities ct = new CTDBEntities();

            lboxDB.DataSource = ct.tbFile.Where(c =>
                                                c.f_pid == ParaDatasetID &&
                                                c.f_filetype == ParaFileType &&
                                                c.f_table == ParaTable).ToList <tbFile>();
            lboxDB.DisplayMember = "f_path";
            lbFileCount.Text     = (lboxDB.DataSource as List <tbFile>).Count.ToString();
        }
Example #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = int.Parse(clID.Text);

            using (var ct = new CTDBEntities())
            {
                var s = ct.tbSlice.FirstOrDefault(st => st.slice_id == id);
                setDBValue(s);
                ct.SaveChanges();
                refreshdata(null, null);
            }
        }
Example #5
0
        private void btnAddSpecies_Click(object sender, EventArgs e)
        {
            FormSpecies dlg = new FormSpecies();

            dlg.ShowDialog();
            CTDBEntities ct = new CTDBEntities();

            csmSpecies.DataSource    = ct.tbSpecies.ToList <tbSpecies>();
            csmSpecies.ValueMember   = "species_id";
            csmSpecies.DisplayMember = "species_latin";
            csmSpecies.SelectedIndex = csmSpecies.Items.Count - 1;
        }
Example #6
0
        private void bsmUpdate_Click(object sender, EventArgs e)
        {
            int id = int.Parse(csmID.Text);

            using (var ct = new CTDBEntities())
            {
                var s = ct.tbSpecimen.FirstOrDefault(st => st.sp_id == id);
                setDBValue(s);
                ct.SaveChanges();
                refreshdata(dataGridView1.SelectedRows[0].Index);
            }
        }
Example #7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int rowid = CTHelper.GetRowIndex(dataGridView1);
            int id    = int.Parse(cscID.Text);

            using (var ct = new CTDBEntities())
            {
                var s = ct.tbScan.FirstOrDefault(st => st.scan_id == id);
                setDBValue(s);
                ct.SaveChanges();
                refreshdata(null, null, rowid);
            }
        }
Example #8
0
 private void ucFileInfo1_UpdateFile(object sender, EventArgs e)
 {
     this.Show();
     using (CTDBEntities ct = new CTDBEntities())
     {
         //更新文件数量
         var s = ct.tbLabel.FirstOrDefault(st => st.label_id == ucFileInfo1.ParaDatasetID);
         if (s != null)
         {
             s.label_file_number = ucFileInfo1.ValueFileCount;
             ct.SaveChanges();
         }
     }
 }
Example #9
0
        private void ucFileInfo1_UpdateFile(object sender, EventArgs e)
        {
            this.Show();
            int id = int.Parse(cscID.Text);

            using (CTDBEntities ct = new CTDBEntities())
            {
                //更新文件数量
                var s = ct.tbScan.FirstOrDefault(st => st.scan_id == id);
                s.scan_para_FilesNumber = ucFileInfo1.ValueFileCount;// q.Count<tbFile>();
                ct.SaveChanges();
            }
            refreshDatagridview(id.ToString());
        }
Example #10
0
        private void bSpeciesUpdate_Click(object sender, EventArgs e)
        {
            int rowid = CTHelper.GetRowIndex(dataGridView1);

            int id = int.Parse(refID.Text);

            using (var db = new CTDBEntities())
            {
                var s = db.tbRef.FirstOrDefault(st => st.ref_id == id);
                setDBValue(s);
                db.SaveChanges();
                refreshdata(null, null, rowid);
            }
        }
Example #11
0
        //add demos from slice
        private void mitCreateExampleFromSlice_Click(object sender, EventArgs e)
        {
            if (!CTHelper.AlertYes("Selecte 10 slices as example?"))
            {
                return;
            }
            CTDBEntities  ct   = new CTDBEntities();
            var           q    = from c in ct.tbFile where c.f_pid == ParaDatasetID && c.f_table == "ctdb-slice" select c;
            List <tbFile> lll  = q.ToList <tbFile>();
            int           spid = ct.tbSlice.Where(c => c.slice_id == ParaDatasetID).Single().tbScan.tbSpecimen.sp_id;

            uploadSpecimenFile(spid, lll, "ctdb-slice", 10);
            refreshdb();
        }
Example #12
0
        /// <summary>查询tbFile表,确定是否有相关联的数据</summary>
        /// <param name="table">表参数</param>
        /// <param name="dsid">表记录id</param>
        /// <returns>ture 有记录,false 无记录</returns>
        static public bool HasFiles(string table, int dsid)
        {
            bool r = true;

            using (var db = new CTDBEntities())
            {
                var student = db.tbFile.FirstOrDefault(s => s.f_table == table && dsid == s.f_pid);
                if (student == null)
                {
                    return(false);
                }
            }
            return(r);
        }
Example #13
0
 /// <summary>set value for combox with Tag </summary>
 /// <param name="cb">combox name</param>
 /// <param name="rootid">parent tag's id </param>
 /// <param name="sid">selected tag's id, -1 means not select</param>
 static public void setControlTag(ComboBox cb, int rootid, int sid = -1)
 {
     using (CTDBEntities ct = new CTDBEntities())
     {
         var q = from c in ct.tbTag where c.tag_pid == rootid select c;
         cb.DataSource    = q.ToList <tbTag>();
         cb.ValueMember   = "tag_id";
         cb.DisplayMember = "tag_tag";
         if (sid != -1)
         {
             CTHelper.setControl(cb, sid);
         }
     }
 }
Example #14
0
        //add demos from labels
        private void mitCreateExampleFromLabel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Selecte 5 labels as example?", "Alert", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            CTDBEntities  ct   = new CTDBEntities();
            var           q    = from c in ct.tbFile where c.f_pid == ParaDatasetID && c.f_table == "ctdb-label" select c;
            List <tbFile> lll  = q.ToList <tbFile>();
            int           spid = ct.tbLabel.Where(c => c.label_id == ParaDatasetID).Single().tbSlice.tbScan.tbSpecimen.sp_id;

            uploadSpecimenFile(spid, lll, "ctdb-label", 5);
            refreshdb();
        }
Example #15
0
        /// <summary>Load data </summary>
        /// <param name="table">table name</param>
        /// <returns></returns>
        static public ArrayList LoadDataF(string table)
        {
            ArrayList    l  = new ArrayList();
            CTDBEntities ct = new CTDBEntities();

            if (table == "tbSpecies")
            {
                foreach (tbSpecies t in ct.tbSpecies.ToList <tbSpecies>())
                {
                    l.Add(t);
                }
            }
            else if (table == "tbRef")
            {
                foreach (tbRef t in ct.tbRef.ToList <tbRef>())
                {
                    l.Add(t);
                }
            }
            else if (table == "tbSpecimen")
            {
                foreach (tbSpecimen t in ct.tbSpecimen.ToList <tbSpecimen>())
                {
                    l.Add(t);
                }
            }
            else if (table == "tbScan")
            {
                foreach (tbScan t in ct.tbScan.ToList <tbScan>())
                {
                    l.Add(t);
                }
            }
            else if (table == "tbSlice")
            {
                foreach (tbSlice t in ct.tbSlice.ToList <tbSlice>())
                {
                    l.Add(t);
                }
            }
            else if (table == "tbLabel")
            {
                foreach (tbLabel t in ct.tbLabel.ToList <tbLabel>())
                {
                    l.Add(t);
                }
            }
            return(l);
        }
Example #16
0
        private void bSpeciesDel_Click(object sender, EventArgs e)
        {
            int id = int.Parse(refID.Text);

            if (MessageBox.Show("Delete " + id.ToString(), "Alert", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (var db = new CTDBEntities())
                {
                    var student = db.tbRef.FirstOrDefault(s => s.ref_id == id);
                    db.tbRef.Remove(student);    //删除萝莉
                    db.SaveChanges();
                    refreshdata(null, null);
                }
            }
        }
Example #17
0
        //public event EventHandler AddFile;

        void refrash()
        {
            using (CTDBEntities ct = new CTDBEntities())
            {
                lbCount.Text = ct.tbFile.Where(c =>
                                               c.f_filetype == ParaFileType &&
                                               c.f_pid == this.ParaDatasetID &&
                                               c.f_table == this.ParaTable).Count <tbFile>().ToString();

                lbCountAll.Text = ct.tbFile.Where(c =>
                                                  c.f_table == this.ParaTable &&
                                                  c.f_pid == this.ParaDatasetID
                                                  ).Count <tbFile>().ToString();
            }
        }
Example #18
0
        /// <summary>浏览器看slice资源信息</summary>
        /// <param name="slice_id"></param>
        static public void OpenSliceInBrowser(int slice_id)
        {
            try
            {
                int id = slice_id;
                //Hashtable ht = new Hashtable();
                List <Tuple <string, string> > ht = new List <Tuple <string, string> >();
                CTDBEntities ct    = new CTDBEntities();
                tbSlice      slice = ct.tbSlice.FirstOrDefault(s => s.slice_id == id);
                string       url   = "http://ct.especies.cn/slice/info/" + slice.slice_id.ToString();

                System.Diagnostics.Process.Start(url);
            }
            catch { }
        }
Example #19
0
        private void viewScanInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id = int.Parse(clID.Text);

            using (CTDBEntities ct = new CTDBEntities())
            {
                //更新文件数量
                var slice = ct.tbSlice.FirstOrDefault(st => st.slice_id == id);
                var scan  = ct.tbScan.FirstOrDefault(st => st.scan_id == slice.scan_id);
                var sp    = ct.tbSpecimen.FirstOrDefault(st => st.sp_id == scan.sp_id);

                string r = "ScanID: " + scan.sp_id + "\r\n";
                r += "Scan Operator: " + scan.scan_operator + "\r\n";
                r += "SecimenSPID: " + sp.sp_spid + "\r\n";
                MessageBox.Show(r);
            }
        }
Example #20
0
        private void beUpdate_Click(object sender, EventArgs e)
        {
            int          id = int.Parse(ceID.Text);
            CTDBEntities db = new CTDBEntities();
            var          s  = db.tbEquipment.FirstOrDefault(st => st.e_id == id);

            s.e_nameA       = ceNameA.Text;
            s.e_name        = ceName.Text;
            s.e_note        = ceNote.Text;
            s.e_location    = ceLocation.Text;
            s.e_type        = ceType.Text;
            s.e_description = ceDescription.Text;
            s.e_contact     = ceContact.Text;
            s.UserId        = Guid.Parse(CTHelper.GetConfig("userid"));
            db.SaveChanges();
            refrashDataGridview(null, null);
        }
Example #21
0
 private void btDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int id = int.Parse(ceID.Text);
         if (CTHelper.AlertYes("Delete " + id.ToString()))
         {
             using (var db = new CTDBEntities())
             {
                 var student = db.tbEquipment.FirstOrDefault(s => s.e_id == id);
                 db.tbEquipment.Remove(student);    //删除
                 db.SaveChanges();
                 refrashDataGridview(null, null);
             }
         }
     }
     catch { MessageBox.Show("Fail to delete, there is related data in database!"); }
 }
Example #22
0
        private void bSpeciesAdd_Click(object sender, EventArgs e)
        {
            tbSpecies s = new tbSpecies();

            setDBValue(s);
            CTDBEntities ct = new CTDBEntities();

            ct.tbSpecies.Add(s);
            ct.SaveChanges();   //将修改保存到数据库中
            if ((dataGridView1.DataSource as List <tbSpecies>) != null)
            {
                refreshdata(null, null, (dataGridView1.DataSource as List <tbSpecies>).Count);
            }
            else
            {
                refreshdata(null, null);
            }
        }
Example #23
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = int.Parse(cscID.Text);

            if (MessageBox.Show("确认删除" + id.ToString(), "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    using (var db = new CTDBEntities())
                    {
                        var student = db.tbScan.FirstOrDefault(s => s.scan_id == id);
                        db.tbScan.Remove(student);    //删除萝莉
                        db.SaveChanges();
                    }
                }
                catch { MessageBox.Show("删除失败,可能有关联数据"); }
            }
            refreshdata(null, null);
        }
Example #24
0
        //=======remote / server=========

        ///remove from database
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("Delete " + lboxDB.SelectedItems.Count.ToString() + " files", "Alert", MessageBoxButtons.YesNo) == DialogResult.Yes)
            if (CTHelper.AlertYes("Delete " + lboxDB.SelectedItems.Count + " files"))
            {
                using (var db = new CTDBEntities())
                {
                    note(lboxDB.Items.Count);
                    foreach (tbFile f in lboxDB.SelectedItems)
                    {
                        var student = db.tbFile.FirstOrDefault(s => s.f_id == f.f_id);
                        db.tbFile.Remove(student);    //删除
                        db.SaveChanges();
                        notep();
                    }
                }
            }
            refreshdb();
        }
Example #25
0
        //load selected information
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                int rid = dataGridView1.SelectedRows[0].Index;
                int id  = ((dataGridView1.DataSource as ArrayList)[rid] as tbSpecimen).sp_id;

                // (int)(dataGridView1.SelectedRows[0].Cells[0].Value as tbSpecimen);
                //tbSpecimen ss = dataGridView1.SelectedRows[0].Cells[0].Value as tbSpecimen;
                //Console.WriteLine(ss.sp_spid.ToString());
                CTDBEntities ct = new CTDBEntities();
                var          q  = from c in ct.tbSpecimen where c.sp_id == id select c;
                tbSpecimen   s  = q.ToList <tbSpecimen>()[0];

                csmID.Text = s.sp_id.ToString();

                csmSPID.Text = s.sp_spid;

                csmCollector.Text    = s.sp_collector;
                csmCollectPlace.Text = s.sp_collect_place;
                csmCollectTime.Text  = s.sp_collect_time;
                csmIdentifier.Text   = s.sp_identifier;

                csmDehydrant.Text     = s.sp_dehydrant;
                csmDryInstrument.Text = s.sp_dryinstrument;
                csmDryCycleTime.Text  = s.sp_drycirletime.ToString();

                CTHelper.setControl(csmSpecies, (int)s.species_id);
                CTHelper.setControl(csmSex, (int)s.specimen_sex);
                csmAge.Text = s.specimen_age;
                csmDriedSpecimenSavePosition.Text = s.specimen_dry_save_path;

                csmPS.Text   = s.sp_preserve_status;
                csmNote.Text = s.sp_note;
                //lbFilecount.Text = ct.tbFile.Where<tbFile>(c => c.f_pid == s.sp_id && c.f_table == "ctdb-specimen").Count<tbFile>().ToString();

                ucFileInfo1.ParaDatasetID = s.sp_id;
                mitDelete.Enabled         = dataGridView1.Rows.Count > 0;

                lbSPcount.Text = ct.tbScan.Where(c => c.sp_id == id).Count <tbScan>().ToString();
            }
        }
Example #26
0
        private void bTagDel_Click(object sender, EventArgs e)
        {
            int id = int.Parse(ctagID.Text);

            if (MessageBox.Show("确认删除" + id.ToString(), "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    using (var db = new CTDBEntities())
                    {
                        var student = db.tbTag.FirstOrDefault(s => s.tag_id == id);
                        db.tbTag.Remove(student);    //删除
                        db.SaveChanges();
                        refreshdata();
                    }
                }
                catch (Exception eeee)
                { MessageBox.Show("Error." + eeee.ToString()); }
            }
        }
Example #27
0
        private void mitExportZipFileForServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ArrayList sl = dataGridView1.DataSource as ArrayList;

            if (sl.Count > 0)
            {
                if (MessageBox.Show("确认打包" + sl.Count + " records?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    string fd = CTHelper.CommonPath() + "\\ctdbr";
                    if (!Directory.Exists(fd))
                    {
                        Directory.CreateDirectory(fd);
                    }
                    progressBar1.Visible = true;
                    progressBar1.Maximum = sl.Count;
                    progressBar1.Value   = 0;
                    using (var db = new CTDBEntities())
                        foreach (tbLabel ts in sl)
                        {
                            progressBar1.Value++;
                            try
                            {
                                //MessageBox.Show(ts.label_id.ToString());
                                tbLabel lb  = db.tbLabel.FirstOrDefault(s => s.label_id == ts.label_id);
                                string  src = lb.label_srcfolder;
                                string  des = fd + "\\" + lb.label_id + ".zip";

                                if (File.Exists(des))
                                {
                                    continue;
                                }
                                CTHelper.ZipDirectory(src, des);
                                System.Threading.Thread.Sleep(500);
                            }
                            catch { }
                        }
                    progressBar1.Visible = false;
                    System.Diagnostics.Process.Start(fd);
                }
            }
        }
Example #28
0
        /// <summary>load/ refresh </summary>
        private void refreshdata(int rowIndex = -1)
        {
            dataGridView1.DataSource = null;
            mitDelete.Enabled        = false;
            CTDBEntities ct = new CTDBEntities();

            //dataGridView1.DataSource = ct.tbSpecimen.ToList<tbSpecimen>();
            //dataGridView1.DataSource = FormLogin.LoadDataA("tbSpecimen");
            //SetColumn(dataGridView1, "sp_id|species_id");
            FormLogin.LoadData(dataGridView1, "tbSpecimen", "sp_id|species_id|sp_collector|Abstract|UserId");
            //dg.DataSource = FormLogin.LoadDataA(table);
            //SetColumn(dg, showcol);

            if (dataGridView1.DataSource != null)
            {
                if (rowIndex > 0)
                {
                    dataGridView1.Rows[rowIndex].Selected = true;
                }
            }
        }
Example #29
0
        /// <summary>set value for combbox </summary>
        /// <param name="cb"></param>
        /// <param name="text"></param>
        static public void LoadControl(ComboBox cb, string table, int id)
        {
            CTDBEntities ct = new CTDBEntities();

            if (table == "tbEquipment")
            {
                cb.DataSource    = ct.tbEquipment.ToList <tbEquipment>();
                cb.DisplayMember = "e_nameA";
            }
            else if (table == "tbSpecimen")
            {
                cb.DataSource    = FormLogin.LoadDataA("tbSpecimen");
                cb.DisplayMember = "Abstract";
            }
            else if (table == "tbRef")
            {
                cb.DataSource    = ct.tbRef.ToList <tbRef>();
                cb.DisplayMember = "cite";
                setControl(cb, id);
            }
        }
Example #30
0
        //equipment
        private void beAdd_Click(object sender, EventArgs e)
        {
            var s = new tbEquipment();

            s.e_nameA       = ceNameA.Text;
            s.e_name        = ceName.Text;
            s.e_note        = ceNote.Text;
            s.e_location    = ceLocation.Text;
            s.e_type        = ceType.Text;
            s.e_description = ceDescription.Text;
            s.date_in       = DateTime.Now;
            s.e_contact     = ceContact.Text;

            s.UserId = Guid.Parse(CTHelper.GetConfig("userid"));

            CTDBEntities ct = new CTDBEntities();

            ct.tbEquipment.Add(s);
            ct.SaveChanges();   //将修改保存到数据库中
            refrashDataGridview(null, null);
        }