예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                DialogResult result;
                result = MessageBox.Show("Are you sure want to Delete the record?", "Conformation", MessageBoxButtons.YesNo);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    string          strDelete = "delete from Patients where id=@id";
                    OleDbCommand    cmd       = new OleDbCommand(strDelete, con);
                    cmd.Parameters.AddWithValue("@id", txtID.Text);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Record Successfully Deleted", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoggingHelper.LogEntry("Patients", "Delete", txtName.Text + "|" + txtBirthday.Text + "|" + txtAddress.Text + "|" + txtHomePhone.Text + "|" + txtMobile.Text +
                                           "|" + comSex.SelectedItem.ToString() + "|" + comBloodGroup.SelectedItem.ToString() + "|" + comMaritalStatus.SelectedItem.ToString() +
                                           "|" + txtNIC.Text + "|" + txtEmail.Text + "|" + txtAge.Text + "|" + txtOccupation.Text, int.Parse(txtID.Text.Trim()));

                    FormRefresh();
                }
            }
        }
예제 #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                DialogResult result;

                result = MessageBox.Show("Are you sure want to Delete the record?", "Conformation", MessageBoxButtons.YesNo);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    string          strDelete = "DELETE FROM Medicines where id=@id";
                    OleDbCommand    cmd       = new OleDbCommand(strDelete, con);
                    cmd.Parameters.AddWithValue("@id", txtID.Text);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Record Successfully Deleted", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoggingHelper.LogEntry("Medicine", "Delete",
                                           txtMedicineName.Text.Trim() + "|" + comGenericName.SelectedValue + "|" + comCompany.SelectedValue + "|" + txtContents.Text.Trim() + "|" + txtPrice.Text.Trim()
                                           + "|" + txtUnits.Text.Trim() + "|" + txtUOM.Text.Trim() + "|" + chkDispensing.Checked + "|" + txtTradeName.Text.Trim(), int.Parse(txtID.Text.Trim()));
                    FormRefresh();
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                DialogResult result;

                result = MessageBox.Show("Are you sure want to Delete the record?", "Conformation", MessageBoxButtons.YesNo);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    string          strDelete = "delete from PharmaceuticalCompanies where id=@id";
                    OleDbCommand    cmd       = new OleDbCommand(strDelete, con);
                    cmd.Parameters.AddWithValue("@id", txtComID.Text);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    DeleteRepData(txtComID.Text);
                    DeleteDistributorData(txtComID.Text);

                    LoggingHelper.LogEntry("Pharmaceutical company", "Delete", txtComName.Text.Trim() + "|" + txtComAddress.Text.Trim() + "|" + txtComPhone.Text.Trim()
                                           + "|" + txtComEmail.Text.Trim(), int.Parse(txtComID.Text.Trim()));
                    MessageBox.Show("Records Successfully  Deleted", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FormRefresh();
                    txtComID.Text = string.Empty;
                }
            }
        }
예제 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                if (btnAdd.Text == "Add")
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    OleDbCommand    cmd       = con.CreateCommand();
                    con.Open();
                    cmd.CommandText = "Insert into Medicines(MedicineName, MedGenericNameID, MedCompanyID, MedContents, MedPrice, MedUnits, MedUoM, MedDispensing, MedTradeName)" +
                                      "Values('" + txtMedicineName.Text.Trim() + "'," +
                                      " " + comGenericName.SelectedValue + ", " +
                                      " " + comCompany.SelectedValue + ", " +
                                      " '" + txtContents.Text.Trim() + "', " +
                                      " " + txtPrice.Text.Trim() + ", " +
                                      " " + txtUnits.Text.Trim() + ", " +
                                      " '" + txtUOM.Text.Trim() + "', " +
                                      " " + chkDispensing.Checked + ", " +
                                      " '" + txtTradeName.Text.Trim() + "')";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "Select @@Identity";
                    int intId = (int)cmd.ExecuteScalar();
                    MessageBox.Show("Record Successfully Saved", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    con.Close();
                    LoggingHelper.LogEntry("Medicine", "Add",
                                           txtMedicineName.Text.Trim() + "|" + comGenericName.SelectedValue + "|" + comCompany.SelectedValue + "|" + txtContents.Text.Trim() + "|" + txtPrice.Text.Trim()
                                           + "|" + txtUnits.Text.Trim() + "|" + txtUOM.Text.Trim() + "|" + chkDispensing.Checked + "|" + txtTradeName.Text.Trim(), intId);
                    FormRefresh();
                }
                else
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    con.Open();
                    string strUpdate = "UPDATE Medicines SET MedicineName = '" + txtMedicineName.Text.Trim() + "', MedGenericNameID = " + comGenericName.SelectedValue + " " +
                                       ", MedCompanyID = " + comCompany.SelectedValue + ", MedContents = '" + txtContents.Text.Trim() + "' " +
                                       ", MedPrice = " + txtPrice.Text.Trim() + ", MedUnits = " + txtUnits.Text.Trim() + " " +
                                       ", MedUoM = '" + txtUOM.Text.Trim() + "', MedDispensing = " + chkDispensing.Checked +
                                       ", MedTradeName = '" + txtTradeName.Text.Trim() + "' WHERE ID = " + txtID.Text.Trim() + "";
                    OleDbCommand cmd = new OleDbCommand(strUpdate, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    LoggingHelper.LogEntry("Medicine", "Update",
                                           txtMedicineName.Text.Trim() + "|" + comGenericName.SelectedValue + "|" + comCompany.SelectedValue + "|" + txtContents.Text.Trim() + "|" + txtPrice.Text.Trim()
                                           + "|" + txtUnits.Text.Trim() + "|" + txtUOM.Text.Trim() + "|" + chkDispensing.Checked + "|" + txtTradeName.Text.Trim(), int.Parse(txtID.Text.Trim()));
                    MessageBox.Show("Record Successfully Updated", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FormRefresh();
                }
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                if (btnAdd.Text == "Add")
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    OleDbCommand    cmd       = con.CreateCommand();
                    con.Open();
                    cmd.CommandText = "Insert into PharmaceuticalCompanies(CompanyName,CompanyAddress,CompanyPhone,CompanyEmail)Values('" + txtComName.Text + "'," +
                                      "'" + txtComAddress.Text + "','" + txtComPhone.Text + "','" + txtComEmail.Text + "')";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "Select @@Identity";
                    int intId = (int)cmd.ExecuteScalar();
                    con.Close();
                    AddRepData(intId.ToString());
                    AddDistributorData(intId.ToString());
                    MessageBox.Show("Record Successfully Saved", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    LoggingHelper.LogEntry("Pharmaceutical company", "Add", txtComName.Text.Trim() + "|" + txtComAddress.Text.Trim() + "|" + txtComPhone.Text.Trim()
                                           + "|" + txtComEmail.Text.Trim(), intId);
                    FormRefresh();
                }
                else
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    con.Open();
                    string strUpdate = "update PharmaceuticalCompanies set " +
                                       "CompanyAddress ='" + txtComAddress.Text.Trim() + "', " +
                                       "CompanyPhone ='" + txtComPhone.Text.Trim() + "'," +
                                       "CompanyEmail ='" + txtComEmail.Text.Trim() + "' where ID=" + txtComID.Text.Trim() + "";
                    OleDbCommand cmd = new OleDbCommand(strUpdate, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    DeleteRepData(txtComID.Text);
                    AddRepData(txtComID.Text);
                    DeleteDistributorData(txtComID.Text);
                    AddDistributorData(txtComID.Text);
                    LoggingHelper.LogEntry("Pharmaceutical company", "Update", txtComName.Text.Trim() + "|" + txtComAddress.Text.Trim() + "|" + txtComPhone.Text.Trim()
                                           + "|" + txtComEmail.Text.Trim(), int.Parse(txtComID.Text.Trim()));
                    MessageBox.Show("Record Successfully Updated", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FormRefresh();
                    txtComID.Text      = string.Empty;
                    txtComName.Enabled = true;
                    btnAdd.Text        = "Add";
                }
            }
        }
예제 #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                if (btnAdd.Text == "Add")
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    OleDbCommand    cmd       = con.CreateCommand();
                    con.Open();
                    cmd.CommandText = "Insert into Patients(FullName, Birthday, Address, HomePhone, Mobile, Sex, BloodGroup, MaritalStatus, NIC, Email, Age, Occupation, RecordNo)" +
                                      "Values('" + txtName.Text + "', '" + txtBirthday.Text + "', '" + txtAddress.Text + "', '" + txtHomePhone.Text + "', '" + txtMobile.Text + "'" +
                                      ", '" + comSex.SelectedItem.ToString() + "', '" + comBloodGroup.SelectedItem.ToString() + "', '" + comMaritalStatus.SelectedItem.ToString() + "'" +
                                      ", '" + txtNIC.Text + "', '" + txtEmail.Text + "', '" + txtAge.Text + "', '" + txtOccupation.Text + "', '" + txtRecordNo.Text + "')";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "Select @@Identity";
                    int intId = (int)cmd.ExecuteScalar();
                    con.Close();
                    MessageBox.Show("Record Successfully Saved", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoggingHelper.LogEntry("Patients", "Add", txtName.Text + "|" + txtBirthday.Text + "|" + txtAddress.Text + "|" + txtHomePhone.Text + "|" + txtMobile.Text +
                                           "|" + comSex.SelectedItem.ToString() + "|" + comBloodGroup.SelectedItem.ToString() + "|" + comMaritalStatus.SelectedItem.ToString() +
                                           "|" + txtNIC.Text + "|" + txtEmail.Text + "|" + txtAge.Text + "|" + txtOccupation.Text + "|" + txtRecordNo.Text, intId);

                    FormRefresh();
                }
                else
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    con.Open();
                    string strUpdate = "update Patients set FullName='" + txtName.Text.Trim() + "', Birthday = '" + txtBirthday.Text + "' " +
                                       ", Address = '" + txtAddress.Text + "', HomePhone = '" + txtHomePhone.Text + "', Mobile = '" + txtMobile.Text + "' " +
                                       ", Sex = '" + comSex.SelectedItem.ToString() + "', BloodGroup = '" + comBloodGroup.SelectedItem.ToString() + "' " +
                                       ", MaritalStatus = '" + comMaritalStatus.SelectedItem.ToString() + "', NIC = '" + txtNIC.Text + "' " +
                                       ", Email = '" + txtEmail.Text + "', Age = '" + txtAge.Text + "', Occupation = '" + txtOccupation.Text + "', RecordNo = '" + txtRecordNo.Text + "'" +
                                       " where ID=" + txtID.Text.Trim() + "";
                    OleDbCommand cmd = new OleDbCommand(strUpdate, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    LoggingHelper.LogEntry("Patients", "Update", txtName.Text + "|" + txtBirthday.Text + "|" + txtAddress.Text + "|" + txtHomePhone.Text + "|" + txtMobile.Text +
                                           "|" + comSex.SelectedItem.ToString() + "|" + comBloodGroup.SelectedItem.ToString() + "|" + comMaritalStatus.SelectedItem.ToString() +
                                           "|" + txtNIC.Text + "|" + txtEmail.Text + "|" + txtAge.Text + "|" + txtOccupation.Text + "|" + txtRecordNo.Text, int.Parse(txtID.Text.Trim()));
                    MessageBox.Show("Record Successfully Updated", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FormRefresh();
                }
            }
        }
예제 #7
0
        private void btnDispense_Click(object sender, EventArgs e)
        {
            string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
            OleDbConnection con       = new OleDbConnection(conString);

            con.Open();

            string strUpdate = "UPDATE PatientsArrival SET PatientStatus = 'Despense' " +
                               " WHERE ID = " + int.Parse(strArrivalID) + " AND PatientID = " + int.Parse(txtID.Text) + "";
            OleDbCommand cmdUpdate = new OleDbCommand(strUpdate, con);

            cmdUpdate.ExecuteNonQuery();

            LoggingHelper.LogEntry("Patients Arrival", "Update", txtID.Text + "|Despense|", int.Parse(strArrivalID));
            con.Close();
        }
예제 #8
0
        private void btnPatientArrived_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                OleDbConnection con       = new OleDbConnection(conString);
                OleDbCommand    cmd       = con.CreateCommand();
                con.Open();
                cmd.CommandText = "Insert into PatientsArrival(PatientID, LogDate, PatientStatus)" +
                                  "Values('" + txtID.Text + "', '" + DateTime.Now + "', 'Arrived')";
                cmd.Connection = con;
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Select @@Identity";
                int intId = (int)cmd.ExecuteScalar();
                con.Close();
                MessageBox.Show("Patient's arrival noticed by the system", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoggingHelper.LogEntry("Patient Arrived", "Add", txtID.Text + "|" + DateTime.Now + "|Arrived", intId);

                FormRefresh();
            }
        }
예제 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                if (btnAdd.Text == "Add")
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    OleDbCommand    cmd       = con.CreateCommand();
                    con.Open();
                    cmd.CommandText = "Insert into GenericNames(GenericName)Values('" + txtGenericName.Text + "')";
                    cmd.Connection  = con;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "Select @@Identity";
                    int intId = (int)cmd.ExecuteScalar();
                    con.Close();
                    MessageBox.Show("Record Successfully Saved", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoggingHelper.LogEntry("Generic Names", "Add", txtGenericName.Text, intId);

                    FormRefresh();
                }
                else
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    con.Open();
                    string       strUpdate = "update GenericNames set GenericName='" + txtGenericName.Text.Trim() + "' where ID=" + txtID.Text.Trim() + "";
                    OleDbCommand cmd       = new OleDbCommand(strUpdate, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    LoggingHelper.LogEntry("Generic Names", "Update", txtGenericName.Text, int.Parse(txtID.Text.Trim()));
                    MessageBox.Show("Record Successfully Updated", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FormRefresh();
                }
            }
        }
예제 #10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!FormValidate())
            {
                DialogResult result;

                result = MessageBox.Show("Are you sure want to Delete the record?", "Conformation", MessageBoxButtons.YesNo);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    string          conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
                    OleDbConnection con       = new OleDbConnection(conString);
                    string          strDelete = "delete from GenericNames where id=@id";
                    OleDbCommand    cmd       = new OleDbCommand(strDelete, con);
                    cmd.Parameters.AddWithValue("@id", txtID.Text);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Records Successfully Deleted", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoggingHelper.LogEntry("Generic Names", "Delete", txtGenericName.Text, int.Parse(txtID.Text.Trim()));
                    FormRefresh();
                }
            }
        }