private void buttonDrugInsert_Click(object sender, EventArgs e) { //-----------------------Insert New Drugs string id = textBoxDrugIdInsert.Text; string name = textBoxDrugName.Text; string givenprice = textBoxDrugPriceInsert.Text; string givencopies = textBoxDrugCopiesInsert.Text; if (id != "" && name != "" && givenprice != "" && givencopies != "") { //---------------------------------------Query For found Id Exist in database string query = "Select COUNT (*) FROM PharmasyTable WHERE Id= '" + id + "'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "0") { //Database int Price = Convert.ToInt16(givenprice); int Copies = Convert.ToInt16(givencopies); ClassInsert.InsertInPharmasyTable(id, name, Price, Copies); MessageBox.Show("Success"); buttonShowPharmasyList_Click(sender, e); } else { MessageBox.Show("Given Id already In Database"); } } else { MessageBox.Show("Please Fill All Field"); } }
public void TestManageInsert() { ClassInsert i = myClass.ManageInsert("INSERT INTO table1 VALUES (10,abc,8);"); string[] values = i.GetValues(); Assert.AreEqual("table1", i.GetTable()); Assert.AreEqual("10", i.GetValues()[0]); Assert.AreEqual("abc", i.GetValues()[1]); Assert.AreEqual("8", i.GetValues()[2]); }
public ClassInsert ManageInsert(String pQuery) { //public const String regExInsert = @"INSERT\s+INTO\s+(\w+)\s+VALUES\s+\(([^\)]+)\);"; Match match = Regex.Match(pQuery, Constants.regExInsert); if (match.Success) { string table = match.Groups[1].Value; string values = match.Groups[2].Value; string[] myArray = values.Split(','); ClassInsert query = new ClassInsert(table, myArray); return(query); } return(null); }
private void buttonNewRegistration_Click(object sender, EventArgs e) { //--------------------------------------------------New Account Registration if (radioButtonAdmin.Checked == false && radioButtonEmployee.Checked == false) { MessageBox.Show("Please Check Admin or Employee", "Check Radio Button", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //----------------Complete Registration string name = textBoxRegName.Text; string username = textBoxRegUN.Text; string password = textBoxRegPW.Text; string mobile = textBoxRegMobile.Text; string address = textBoxRegAddress.Text; if ((radioButtonAdmin.Checked == true && username.StartsWith("a")) || (radioButtonEmployee.Checked == true && username.StartsWith("e"))) { string query = "Select COUNT (*) FROM AccountTable WHERE Username= '******'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "0") { ClassInsert.InsertAdminEmployeeRegistration(name, username, password, mobile, address); MessageBox.Show("Success"); } else { MessageBox.Show(username + " Username Already Exist"); } } else { MessageBox.Show("Admin Username must start with (a) and\nEmployee Username must start with (e)", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void buttonCompleteRegistration_Click(object sender, EventArgs e) { if (checkBoxDonorAgree.Checked) { //-------------------------------------taking data for Donor Registration string name = textBoxDonorName.Text; string mobile = textBoxDonorMobile.Text; int age = Convert.ToInt16(numericUpDownDonorAge.Value); string sex = comboBoxDonorSex.Text; string address = textBoxDonorAddress.Text; string bloodGroup = ""; if (radioButtonAp.Checked) { bloodGroup = "A+"; } if (radioButtonAm.Checked) { bloodGroup = "A-"; } if (radioButtonABp.Checked) { bloodGroup = "AB+"; } if (radioButtonABm.Checked) { bloodGroup = "AB-"; } if (radioButtonBp.Checked) { bloodGroup = "B+"; } if (radioButtonBm.Checked) { bloodGroup = "B-"; } if (radioButtonOp.Checked) { bloodGroup = "O+"; } if (radioButtonOm.Checked) { bloodGroup = "O-"; } if (mobile.Length == 14 && bloodGroup != "") { //---------------------------------Check for mobile existance string query = "Select COUNT (*) FROM DonorTable WHERE Mobile= '" + mobile + "'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "0") { //-----------------------------------All Data Get Successfully,Insert in Database ClassInsert.InsertRegistrationDonorTable(mobile, bloodGroup, name, address, sex, age); } else { MessageBox.Show("This number is Already registered Before"); } } else { string message = "Mobile Number Must Be valied(14 Number with +880) \nMust Check Your Blood GrouP"; MessageBox.Show(message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("You Must Need To Agree", "Message"); } }