private void rbnCboPatName_SelectedIndexChanged(object sender, EventArgs e) { //Select category to delete : try { string name = rbnCboPatName.SelectedItem; DBC.CommandText = "SELECT * FROM Patiant WHERE Name='" + name + "';"; DataSet ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { rbnTxtPID.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString(); rbnTxtPatAge.Text = ds.Tables[0].Rows[0].ItemArray[2].ToString(); rbnTxtPatInfo.Text = ds.Tables[0].Rows[0].ItemArray[3].ToString(); } if (opr.ToLower() == "modify") { rbnCboPatName.ReadOnly = false; } else { rbnCboPatName.ReadOnly = true; } } catch (Exception ex) { MessageBox.Show( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void viewAllImages() { try { DBC.CommandText = "SELECT * FROM IMAGE"; DataSet ds = DBC.ExecuteQuery(); DataSet sds; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string fname = ds.Tables[0].Rows[i].ItemArray[1].ToString(); string imgID = ds.Tables[0].Rows[i].ItemArray[0].ToString(); double sid = Math.Floor((double.Parse(imgID) / 100)); DBC.CommandText = "SELECT FolderPath FROM Series WHERE SID = " + sid.ToString() + " ;"; sds = DBC.ExecuteQuery(); if (sds.Tables[0].Rows.Count < 1) { return; } string imgFld = sds.Tables[0].Rows[0].ItemArray[0].ToString(); imgFld = (imgFld.EndsWith("\\")) ? imgFld : imgFld + "\\"; imgFld = (imgFld.StartsWith("\\")) ? imgFld : "\\" + imgFld; string imgpath = this.SC.SettingsList[0].TrimEnd('\\') + imgFld + fname; Bitmap bmp = new Bitmap(imgpath); PureComponents.EntrySet.Lists.PictureListItem pItem = new PureComponents.EntrySet.Lists.PictureListItem(fname, bmp, true, null); pItem.Tag = imgpath; imageRecord imgRecord = new imageRecord(imgID, null, fname, null); pItem.Value = imgRecord; picLstResults.Items.Add(pItem); } rbnMain.StatusBar.Text = "Database is connected."; rbnMain.StatusBar.Text = rbnMain.StatusBar.Text + " - - - - You have " + picLstResults.Items.Count + " images in the database"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error viewing all images", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void rbnCboCatName_SelectedIndexChanged(object sender, EventArgs e) { //Select category to delete : try { string name = rbnCboCatName.SelectedItem; DBC.CommandText = "SELECT CatID,CatParentID FROM Category WHERE CatName='" + name + "';"; DataSet ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { rbnTxtCatID.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString(); rbnCboCatParent.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString(); } } catch (Exception ex) { MessageBox.Show( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void rbnCboSeriesID_SelectedIndexChanged(object sender, EventArgs e) { try { int SID = int.Parse(rbnCboSeriesID.SelectedItem); if (DBC.IsConnected) { //Firstly check all categories of this series with ID : SID #region Check Categories DBC.CommandText = "SELECT CatID FROM Series_Cats where SID= " + SID.ToString() + " ;"; DataSet ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < mListCats.Items.Count; i++) { mListCats.Items[i].CheckState = CheckState.Unchecked; } for (int i = 0; i < mListCats.Items.Count; i++) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { if (mListCats.Items[i].Description == ds.Tables[0].Rows[j].ItemArray[0].ToString()) { mListCats.Items[i].CheckState = CheckState.Checked; } } } } #endregion //Secondly fill the images of this series with ID (SID) in the picture list : #region Fill Picture List //Bring all images in the series DBC.CommandText = "SELECT ImageID,FileName FROM Image where FLOOR(ImageID/100)= " + SID.ToString() + " ;"; ds = DBC.ExecuteQuery(); //Bring the folder where images of series are copied DBC.CommandText = "SELECT FolderPath FROM Series WHERE SID = " + SID.ToString() + " ;"; DataSet sds = DBC.ExecuteQuery(); //Images folder is . . . string imgFld = sds.Tables[0].Rows[0].ItemArray[0].ToString(); //Now put all images in the series in the picture list (picLstSerImage) for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string fname = ds.Tables[0].Rows[i].ItemArray[1].ToString(); string ImageID = ds.Tables[0].Rows[i].ItemArray[0].ToString(); imgFld = (imgFld.EndsWith("\\")) ? imgFld : imgFld + "\\"; imgFld = (imgFld.StartsWith("\\")) ? imgFld : "\\" + imgFld; string imgpath = this.SC.SettingsList[0].TrimEnd('\\') + imgFld + fname; Bitmap bmp = new Bitmap(imgpath); PictureListItem pItem = new PictureListItem(fname, bmp, true, null); ImageRecord = new imageRecord(ImageID, null, fname, null); pItem.Value = ImageRecord; pItem.Tag = imgpath; picLstSerImage.Items.Add(pItem); } #endregion //And finally fill the notes about the series #region Fill Series Notes DBC.CommandText = "SELECT Notes FROM Series_Notes where SID= " + SID.ToString() + " ;"; ds = DBC.ExecuteQuery(); if (ds.Tables[0].Rows.Count > 0) { rbnTxtNotes.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString(); } #endregion } else { throw new Exception("The database is not connected"); } #region Operations related to specific kind of data manipulation if (opr.ToLower() == "modify") //Modification { rbnBtnNotes.Visible = true; rbnBtnAddImage.Visible = true; rbnBtnRemoveImage.Visible = true; rbnBtnDelAll.Visible = true; rbnBtnManipulate.Visible = true; allowPatiantChange = true; } else //Deletion { int[] to_delete = new int[mListCats.Items.Count]; int j = 0; for (int i = 0; i < mListCats.Items.Count; i++) { if (mListCats.Items[i].CheckState == CheckState.Unchecked) { to_delete[j] = i; j++; } } for (int i = j; i >= 0; i--) { mListCats.Items.RemoveAt(i); } mListCats.ShowCheck = false; } #endregion } catch (Exception ex) { MessageBox.Show( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }