Example #1
0
        private List <int> CreateCompoundIDList()
        {
            List <int> lstCompoundsOnReagentID = new List <int>();

            DB_Operator dbo = new DB_Operator();
            DataTable   dt3 = dbo.GetTable("Compound_Data");

            List <int>    lstCompoundCodes = new List <int>();
            List <string> lstCompoundNames = new List <string>();

            for (int i = 0; i < dt3.Rows.Count; i++)
            {
                lstCompoundCodes.Add(Convert.ToInt32(dt3.Rows[i].ItemArray[0]));
                lstCompoundNames.Add(Convert.ToString(dt3.Rows[i].ItemArray[1]));
            }

            for (int i = 0; i < lstCompoundsOnReagent.Count; i++)
            {
                if (lstCompoundsOnReagent[i].Trim() == "")
                {
                    lstCompoundsOnReagentID.Add(0000);
                }
                else
                {
                    int index = lstCompoundNames.IndexOf(lstCompoundsOnReagent[i]);
                    lstCompoundsOnReagentID.Add(lstCompoundCodes[index]);
                }
            }

            return(lstCompoundsOnReagentID);
        }
Example #2
0
        private void InsertData()
        {
            DB_Operator dbo = new DB_Operator();

            List <int> lstCompoundsOnReagentID = CreateCompoundIDList();

            dbo.InsertChemicalCompound(nameOftheChemicalCompound, lstColumnCodes, lstCompoundsOnReagentID, state, colorCode, ColorName, odor);
        }
Example #3
0
        private void btnRemoveOperation_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure to remove the selected operation from the database?", "", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                int         index = lstBoxOperations.SelectedIndex;
                DB_Operator dbo   = new DB_Operator();
                dbo.RemoveReagentOrOperation("Operation_Data", "Operation_Code", lstOperationCodes[index]);
                lstBoxOperations.Items.RemoveAt(index);
                lstOperationCodes.RemoveAt(index);
            }
        }
Example #4
0
        private void LoadControls()
        {
            DB_Operator dbo = new DB_Operator();
            DataTable   dt1 = dbo.GetTable("Reagent_Data");
            DataTable   dt2 = dbo.GetTable("Operation_Data");
            DataTable   dt3 = dbo.GetTable("Compound_Data");

            foreach (DataRow dr in dt1.Rows)
            {
                lstColumnCodes.Add(dr.ItemArray[1] as string);
                lstColumnNames.Add(dr.ItemArray[2] as string);
            }

            foreach (DataRow dr in dt2.Rows)
            {
                lstColumnCodes.Add(dr.ItemArray[1] as string);
                lstColumnNames.Add(dr.ItemArray[2] as string);
            }


            Point lblPosition    = new Point(40, 63);
            Point txtBoxPosition = new Point(237, 60);

            for (int i = 0; i < lstColumnCodes.Count; i++)
            {
                Label lblReagent = new Label();
                lblReagent.Size = new System.Drawing.Size(194, 15);

                lblReagent.Name     = "lblReagent_" + i.ToString();
                lblReagent.Location = lblPosition;
                this.pnlChemicalCompound.Controls.Add(lblReagent);

                lblReagent.Text = lstColumnNames[i];

                ComboBox cmbBoxCompound = new ComboBox();
                cmbBoxCompound.Name     = i.ToString();
                cmbBoxCompound.Location = txtBoxPosition;
                this.pnlChemicalCompound.Controls.Add(cmbBoxCompound);

                for (int j = 0; j < dt3.Rows.Count; j++)
                {
                    cmbBoxCompound.Items.Add(dt3.Rows[j].ItemArray[1]);
                }

                lblPosition.Y    += 37;
                txtBoxPosition.Y += 37;
            }
        }
Example #5
0
        private void PerformFileOperation()
        {
            //Get the path of the application folder..
            //string currentPath = Directory.GetCurrentDirectory();
            ////define a path to create a new directory "temp"...

            string currentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "University of Colombo\\Analytica Lab\\");
            string filePath    = Path.Combine(currentPath, "temp");


            //if the temp folder already exists, delete it..
            if (Directory.Exists(filePath))
            {
                Directory.Delete(filePath, true);
            }

            //create temp directory..
            Directory.CreateDirectory(filePath);

            //copy restoring datafiles into application folder..
            File.Copy(txtBoxMdfLocation.Text, filePath + "\\Analytica_Lab.mdf");
            File.Copy(txtBoxLdfLocation.Text, filePath + "\\Analytica_Lab_log.ldf");


            //check whether the new database is compatible.. if not, delete new data files and rollback process..
            bool isDatabaseCompatible = true;



            using (DB_Operator dbo = new DB_Operator())
            {
                isDatabaseCompatible = dbo.TestDataBase();
            }



            if (isDatabaseCompatible == true)
            {
                File.Delete(currentPath + "\\Analytica_Lab.mdf");
                File.Delete(currentPath + "\\Analytica_Lab_log.ldf");

                File.Copy(txtBoxMdfLocation.Text, currentPath + "\\Analytica_Lab.mdf");
                File.Copy(txtBoxLdfLocation.Text, currentPath + "\\Analytica_Lab_log.ldf");
            }
        }
Example #6
0
        private void ValidateInput()
        {
            if (this.txtBoxOperationName.Text.Trim() == null)
            {
                throw new Exception("Please insert a proper reagent name...!");
            }
            else
            {
                if (isNewOperation == true)
                {
                    bool   isExisting    = false;
                    string operationCode = "";

                    do
                    {
                        operationCode = frmReagentWizard.GenerateCode(6);
                        foreach (string s in lstOperationCodes)
                        {
                            if (s.Trim() == operationCode.Trim())
                            {
                                isExisting = true;
                                break;
                            }
                        }
                    }while (isExisting == true);


                    DB_Operator dbo = new DB_Operator();
                    dbo.InsertReagentOrOperation("Operation_Data", "Operation_Code", "Operation_Name", "Image_Link", "Op_" + operationCode, txtBoxOperationName.Text, "operation.png");
                    txtBoxOperationName.Clear();
                    grpBoxAddOperation.Hide();
                    this.Size = new Size(392, 300);
                }
                else
                {
                    int         index = lstBoxOperations.SelectedIndex;
                    DB_Operator dbo   = new DB_Operator();
                    dbo.UpdateReagentOrOperation("Operation_Data", "Operation_Code", "Operation_Name", lstOperationCodes[index], txtBoxOperationName.Text);
                    txtBoxOperationName.Clear();
                    grpBoxAddOperation.Hide();
                    this.Size = new Size(392, 300);
                }
            }
        }
Example #7
0
        private void LoadOperationData()
        {
            if (lstBoxOperations.Items.Count != 0)
            {
                lstBoxOperations.Items.Clear();
                lstOperationCodes.Clear();
                lstImageLinks.Clear();
            }

            lstBoxOperations.Refresh();
            DB_Operator dbo = new DB_Operator();
            DataTable   dt  = dbo.GetTable("Operation_Data");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                lstBoxOperations.Items.Add(dt.Rows[i].ItemArray[2] as string);
                lstOperationCodes.Add(dt.Rows[i].ItemArray[1] as string);
                lstImageLinks.Add(dt.Rows[i].ItemArray[3] as string);
            }
            lstBoxOperations.Refresh();
        }