Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DBconnection ob = new DBconnection();

            ob.priceList();
            if (!ob.checkUserName("admin"))
            {
                byte[]   bytes = Encoding.ASCII.GetBytes("0x53797374656D2E427974655B5D");
                employee ox    = new employee("admin", "admin", "1997/06/02", "admin", 123, "Admin", "admin", "admin", bytes);
                ob.addEmployees(ox);
            }
            else
            {
                return;
            }
        }
        private void displayAvailableReports()
        {
            try
            {
                DBconnection connection5 = new DBconnection();

                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(connection5.displayMLTAvailableReports());
                da.Fill(dt);
                dataGrid.DataSource = dt;
                connection5.getConnection().Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in display Reports:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (notifi.Text.Trim() == string.Empty || nType.Text.Trim() == string.Empty || about.Text.Trim() == string.Empty)
     {
         MessageBox.Show("Empty Fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         string selected = this.nType.GetItemText(this.nType.SelectedItem);
         showNotification(notifi.Text, selected);
         DBconnection ob        = new DBconnection();
         string       messageId = primaryKey.RandomString(6);
         Message      ox        = new Message(messageId, notifi.Text, nType.Text);
         ob.messageDatebase(ox);
         clear();
     }
 }
Beispiel #4
0
        private void displayAvailableReports()
        {
            try
            {
                DBconnection connection5 = new DBconnection();

                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(connection5.displayAvailableReports());
                da.Fill(dt);
                dataGrid.DataSource = dt;
                connection5.getConnection().Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Displaying Reports:\n" + ex, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Console.WriteLine("Error: \n" + ex);
            }
        }
Beispiel #5
0
        private void guna2Button1_Click(object sender, EventArgs e)
        {
            try
            {
                String name  = txtName.Text;
                double price = Convert.ToDouble(txtPrice.Text);

                DBconnection ob = new DBconnection();
                ob.updatePriceList(name, price);
                clear();
                displayPriceList();
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error Update! \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        public void PatientReports()
        {
            //string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff",CultureInfo.InvariantCulture)+ primaryKey.RandomString(5);
            //MessageBox.Show("time: " + timestamp);
            try
            {
                DBconnection connection5 = new DBconnection();

                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(connection5.displayAllPatientsReports());
                da.Fill(dt);
                dataGrid.DataSource = dt;
                connection5.getConnection().Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Displaying: \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.WriteLine("Error:\n" + ex);
            }
        }
Beispiel #7
0
        private void guna2Button1_Click(object sender, EventArgs e)
        {
            string date1 = dateOne.ToString();
            string date2 = dateTwo.ToString();

            try
            {
                DBconnection connection5 = new DBconnection();

                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(connection5.displayReportBetweentwodays(date1, date2));
                da.Fill(dt);
                dataGrid.DataSource = dt;
                connection5.getConnection().Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Displaying Reports:\n" + ex, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Console.WriteLine("Error: \n" + ex);
            }
        }
 private void guna2Button4_Click(object sender, EventArgs e)
 {
     try
     {
         if (nic.Text.Trim() != string.Empty && test.Text.Trim() != string.Empty)
         {
             using (OpenFileDialog dig = new OpenFileDialog {
                 Filter = "PDF Documents(*.pdf) | *.pdf", ValidateNames = true
             })
             {
                 if (dig.ShowDialog() == DialogResult.OK)
                 {
                     DialogResult dialog = MessageBox.Show("Are you sure want to upload?", "File Upload", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dialog == DialogResult.Yes)
                     {
                         string       finishedDate = DateTime.Today.ToString();
                         string       filename     = dig.FileName;
                         DBconnection ob           = new DBconnection();
                         ob.uploadReport(filename, reportNumber, patientNic, finishedDate);
                     }
                 }
             }
             clear();
             displayAvailableReports();
         }
         else
         {
             MessageBox.Show("Empty Fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error upload file:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Console.WriteLine("upload: \n" + ex);
     }
     displayAvailableReports();
 }
Beispiel #9
0
        private void guna2Button1_Click(object sender, EventArgs e)
        {
            //int logCount = 0;
            bool permission = false;

            if (uName.Text.Trim() != string.Empty && pWord.Text.Trim() != string.Empty)
            {
                try
                {
                    login        ob = new login(uName.Text, pWord.Text);
                    DBconnection ox = new DBconnection();
                    permission = ox.adminLogin(ob);


                    if (permission == true)
                    {
                        thread = new Thread(openFront);
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                        Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Invalid User Name or Password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Empty Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        private void guna2Button3_Click(object sender, EventArgs e)
        {
            DBconnection ui   = new DBconnection();
            string       type = empType.Text;



            if (name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Name Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (nic.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty NIC Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (dob.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty DOB Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (email.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Email Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (empType.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Enter Designation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //!type.Equals("MLT") || !type.Equals("Cashier") || !type.Equals("Admin") || !type.Equals("Other")
            else if (empType.Text.Trim() != string.Empty)
            {
                if (type.Equals("MLT"))
                {
                }
                else if (type.Equals("Casheir"))
                {
                }
                else if (type.Equals("Admin"))
                {
                }
                else if (type.Equals("Other"))
                {
                    if (other.Text.Trim() == string.Empty)
                    {
                        MessageBox.Show("Empty Other Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Enter valid Designation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (phone.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Phone Number Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            else
            {
                return;
            }

            if (user.Checked)
            {
                if (userName.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Empty UserName Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (password.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Empty Password Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (cPassword.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Empty Confirm Password Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (password.Text != cPassword.Text)
                {
                    MessageBox.Show("Password does not match!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (ui.checkUserName(userName.Text))
                {
                    MessageBox.Show("Username Already Taken!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            DialogResult answer;

            answer = MessageBox.Show("Are you sure want to add Employee?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


            //*************database**********************
            if (answer == DialogResult.Yes || answer == DialogResult.OK)
            {
                try
                {
                    MemoryStream ms  = new MemoryStream();
                    byte[]       img = ms.ToArray();
                    if (pictureBox1.Image == null)
                    {
                        MessageBox.Show("Empty Image!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
                    }


                    string   Enic      = "E" + nic.Text;
                    string   Ename     = name.Text;
                    string   date      = dob.Value.ToShortDateString();
                    string   Eemail    = email.Text;
                    int      Ephone    = Convert.ToInt32(phone.Text);
                    string   eType     = empType.Text;
                    string   Eusername = userName.Text;
                    string   Epassword = password.Text;
                    byte[]   Photo     = img;
                    employee ox        = new employee(Enic, Ename, date, Eemail, Ephone, eType, Eusername, Epassword, Photo);

                    ui.addEmployees(ox);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("erro: \n" + ex);
                    Console.WriteLine("erro: \n" + ex);
                }


                clearFileds();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (core.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Chemical or ID Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Name Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (price.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Price Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (quantity.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Quantity Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                DialogResult answer;
                answer = MessageBox.Show("Are you sure want to add Employee?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (answer == DialogResult.Yes)
                {
                    //******database connect ******
                    try
                    {
                        string date1 = date.Value.ToString();
                        if (core.Text.Equals("Chemical") || core.Text.Equals("Equipment"))
                        {
                            //float cPrice = float.Parse(price.Text);
                            string cPrice     = price.Text;
                            string cQuantity  = quantity.Text + cmbQuantity.Text;
                            string cReference = reference.Text;
                            string cName      = name.Text;

                            DBconnection dbconnection = new DBconnection();

                            if (dbconnection.findChemicalEquipment(cName))
                            {
                                string currentQuantity = dbconnection.getCurrentQuantity(name.Text);
                                int    q           = Convert.ToInt32(currentQuantity) + Convert.ToInt32(cQuantity);
                                string newQuantity = q.ToString();
                                dbconnection.updateChemicalAndEquipment(cName, newQuantity);
                            }
                            else
                            {
                                chemicalsAndEquipments chemicalsAndequipments = new chemicalsAndEquipments(date1, cName, cPrice, cQuantity, global.UserID, cReference);

                                dbconnection.addChemicalsAndEquipments(chemicalsAndequipments);
                            }
                            availableEquipmentsAndChemicals();
                            clearFileds();
                        }
                        else
                        {
                            MessageBox.Show("Enter valid Type(Chemical or Equipment)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Console.WriteLine("Error: \n" + ex);
                    }
                }
            }
        }
Beispiel #12
0
        private void guna2ImageButton6_Click_1(object sender, EventArgs e)
        {
            DBconnection ui = new DBconnection();

            ui.showNotificationTimeToTime();
        }
Beispiel #13
0
 public Front()
 {
     InitializeComponent();
     DBconnection ox = new DBconnection();
     //Console.WriteLine("me me: " + global.UserID);
 }
Beispiel #14
0
        private void guna2Button4_Click(object sender, EventArgs e)
        {
            if (name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty UserName Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (nic.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty NIC Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (contact.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Contact Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (address.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Address Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (!male.Checked && !female.Checked && !other.Checked)
            {
                MessageBox.Show("Select Gender!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (paidAmount.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Empty Paid Amount Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                DialogResult answer;
                answer = MessageBox.Show("Are you sure want to Confirm Payment?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (answer == DialogResult.Yes)
                {
                    try
                    {
                        //******patient database*****//
                        DBconnection connection     = new DBconnection();
                        string       selectedGender = "";
                        if (male.Checked)
                        {
                            selectedGender = "Male";
                        }
                        else if (female.Checked)
                        {
                            selectedGender = "Female";
                        }
                        else
                        {
                            selectedGender = "Other";
                        }
                        var  dateOf         = dob.Value;
                        bill patientDetails = new bill(nic.Text, name.Text, dateOf.Date.ToString(), selectedGender, address.Text, Convert.ToInt32(contact.Text));


                        if (!connection.searchPatient(nic.Text))
                        {
                            connection.addPatient(patientDetails);
                        }

                        //******bill database******//

                        string billNumber   = "B" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        string date         = DateTime.UtcNow.Date.ToString();
                        string requiredDate = rDate.Value.ToShortDateString();
                        double total1       = Convert.ToDouble(total.Text);

                        bill billDetails = new bill(billNumber, date, requiredDate, global.UserID, nic.Text, total1, des.Text);

                        connection.addInvoice(billDetails);


                        //******report database******//
                        foreach (global.reportStruct i in reportList)
                        {
                            report       patientReport = new report(nic.Text, i.stReportNumber, i.stTest, i.stRequiredDate);
                            DBconnection connection1   = new DBconnection();
                            connection1.Report(patientReport);
                        }

                        displayAvailableReports();
                        reportList.Clear();
                        clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Console.WriteLine("Error:\n" + ex);
                    }
                }
            }
        }
Beispiel #15
0
        private void guna2Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string       patientNic  = nic.Text;
                DBconnection connection2 = new DBconnection();

                if (connection2.searchPatient(patientNic))
                {
                    int       counter             = 0;
                    ArrayList patientDetailsArray = new ArrayList();
                    //MessageBox.Show("Patient Found?", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    patientDetailsArray = connection2.getPatientDetails(patientNic);

                    foreach (string i in patientDetailsArray)
                    {
                        Console.WriteLine("\n console: " + i + " counter: " + counter);
                        if (counter == 0)
                        {
                            name.Text = i;
                        }
                        if (counter == 1)
                        {
                            dob.Value = DateTime.Parse(i);
                        }
                        //if (counter == 0)
                        //{
                        //    name.Text = i;
                        //}
                        if (counter == 2)
                        {
                            if (i.Equals("Male"))
                            {
                                male.Checked = true;
                            }
                            else if (i.Equals("Female"))
                            {
                                female.Checked = true;
                            }
                            else
                            {
                                other.Checked = true;
                            }
                        }
                        if (counter == 4)
                        {
                            contact.Text = i;
                        }
                        else
                        {
                            address.Text = i;
                        }
                        counter++;
                    }
                }
                else
                {
                    MessageBox.Show("No Patient Found?", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No Patient Found ?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.WriteLine("error search: " + ex);
            }
        }
Beispiel #16
0
        public void cashInHand()
        {
            DBconnection connection5 = new DBconnection();

            cash.Text = connection5.displayCashInHand(date);
        }