private void buttonUpdateCopies_Click(object sender, EventArgs e) { //----------------------Update Copies of Drugs string givenID = textBoxDrugIdUpdateCopies.Text; string givenCopies = textBoxUpdateCopies.Text; if (givenID != "" && givenCopies != "") { //---------------------------------------Query For found Id Exist in database string query = "Select COUNT (*) FROM PharmasyTable WHERE Id= '" + givenID + "'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "1") { //Database int Copies = Convert.ToInt16(givenCopies); string colmnName = "Copies"; ClassUpdate.UpdateAnyForPharmasy(colmnName, givenID, Copies); MessageBox.Show("Success"); buttonShowPharmasyList_Click(sender, e); } else { MessageBox.Show("ID " + givenID + " Not Found"); } } else { MessageBox.Show("Please Fill All Field"); } }
public void TestManageUpdate() { ClassUpdate u = myClass.ManageUpdate("UPDATE table1 SET nombre=Ana,edad=20 WHERE nombre=Maria;"); string[] columns = u.GetColumns(); Assert.AreEqual("table1", u.GetTable()); Assert.AreEqual("nombre=Ana", u.GetColumns()[0]); Assert.AreEqual("edad=20", u.GetColumns()[1]); Assert.AreEqual("nombre=Maria", u.GetCondition()); }
private void buttonSellDrug_Click(object sender, EventArgs e) { string drugSellId = textBoxDrugId.Text; string col = textBoxCollected.Text; string ret = textBoxReturned.Text; string query2 = "Select COUNT (*) FROM PharmasyTable WHERE Id= '" + drugSellId + "'"; DataTable dt2 = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query2, dt2); string truevalue = dt2.Rows[0][0].ToString(); if (truevalue == "1") { if (drugSellId != "" && col != "" && ret != "") //------------- For Exception Handel (Sell Button Click Without Input) { string query = "SELECT Price , Name ,Copies, SoldCopies FROM PharmasyTable WHERE Id= '" + drugSellId + "' "; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); int orginalPrice = Convert.ToInt16(dt.Rows[0][0].ToString()); string drugName = dt.Rows[0][1].ToString(); int RemainCopies = Convert.ToInt16(dt.Rows[0][2].ToString()); int SoldCopies = Convert.ToInt16(dt.Rows[0][3].ToString()); int collected = Convert.ToInt16(col); int returned = Convert.ToInt16(ret); if (((collected - returned) == orginalPrice) && RemainCopies > 0) { string colmnName = "Copies"; ClassUpdate.UpdateAnyForPharmasy(colmnName, drugSellId, RemainCopies - 1); string colmnName2 = "SoldCopies"; ClassUpdate.UpdateAnyForPharmasy(colmnName2, drugSellId, SoldCopies + 1); ClassUpdate.UpdatePharmasySoldStatus(drugSellId); MessageBox.Show("This Producted is sold, Now Print Recipt", "Success"); printReceipt(drugSellId, drugName, collected, returned, orginalPrice); } else { MessageBox.Show("Sell Not Possible ", "Price Not Matched", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Fill All Box ", "Enter All Textbox", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("This Id Is not Exist In Database"); } }
private void buttonChangeAddress_Click(object sender, EventArgs e) { //-------------------Change Admin Address string GivenChange = textBoxAddress.Text; string ColmnName = "Address"; int ColmnMaxValue = 50; ClassUpdate.UpdateAdminsAnyInfo(ColmnName, ColmnMaxValue, adminUsername, GivenChange); MessageBox.Show("Success"); buttonShowAdminDGV_Click(sender, e); }
public ClassUpdate ManageUpdate(string pQuery) { Match Update = Regex.Match(pQuery, Constants.regExpUpdate); if (Update.Success) { string Table = Update.Groups[0].Value; string Column = Update.Groups[1].Value; string[] ColumnSplit = Column.Split(','); string Condition = Update.Groups[2].Value; ClassUpdate query = new ClassUpdate(Table, ColumnSplit, Condition); return(query); } return(null); }
private void buttonAddDonorComment_Click(object sender, EventArgs e) { //--------------------Adding Donor Comment string DonorMobile = textBoxDonorIdToAddComment.Text; if (DonorMobile != "") { //---------------------------------------Query For found Id Exist in database string query = "Select COUNT (*) FROM DonorTable WHERE Mobile= '" + DonorMobile + "'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "1") { if (radioButtonActive.Checked) { string comment = "Active " + DateTime.Now.ToString(); ClassUpdate.UpdateDonorComment(DonorMobile, comment); MessageBox.Show("Success"); buttonShowDonorList_Click(sender, e); } else if (radioButtonNoComment.Checked) { string comment = ""; ClassUpdate.UpdateDonorComment(DonorMobile, comment); MessageBox.Show("Success"); buttonShowDonorList_Click(sender, e); } else { MessageBox.Show("Please Check A RadioButton"); } } else { MessageBox.Show("This Mobile No Foun in Database"); } } else { MessageBox.Show("Please Enter Mobile No"); } }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <update> <CLASS> <CLASSID>C1234</CLASSID> <NAME>hello world</NAME> </CLASS> </update> </function>"; ClassUpdate record = new ClassUpdate("unittest") { ClassId = "C1234", ClassName = "hello world" }; this.CompareXml(expected, record); }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <update> <CLASS> <CLASSID>C1234</CLASSID> <NAME>hello world</NAME> </CLASS> </update> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); ClassUpdate record = new ClassUpdate("unittest"); record.ClassId = "C1234"; record.ClassName = "hello world"; record.WriteXml(ref xml); xml.Flush(); stream.Position = 0; StreamReader reader = new StreamReader(stream); Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd()) .WithDifferenceEvaluator(DifferenceEvaluators.Default) .Build(); Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString()); }