private void buttonDrugDelete_Click(object sender, EventArgs e) { //----------------------Delete Drug Form PharmasyTable string drugId = textBoxDrugIdDelete.Text; if (drugId != "") { //---------------------------------------Query For found Id Exist in database string query = "Select COUNT (*) FROM PharmasyTable WHERE Id= '" + drugId + "'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string truevalue = dt.Rows[0][0].ToString(); if (truevalue == "1") { //Database ClassDelete.DeleteDrugItem(drugId); MessageBox.Show("Success"); buttonShowPharmasyList_Click(sender, e); } else { MessageBox.Show("ID " + drugId + " Not Found"); } } else { MessageBox.Show("Please Fill All Field"); } }
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"); } }
private void Listen() { while (true) { try { if (listener.IsListening) { var context = listener.GetContext(); // Console.WriteLine("context= {0} | {1}", context.Request, context.Request.Headers); Task.Run(() => HandleContextAsync(context)); } else { Thread.Sleep(0); } } catch (ThreadAbortException) { return; } catch (Exception error) { ClassCommon.WriteLine("=>{0} An Error occurred: {1} Message: {2} {3}", DateTime.Now, error.StackTrace, error.Message, Environment.NewLine); } } }
private void buttonDeleteDonorInfo_Click(object sender, EventArgs e) { //----------------------Delete Donor from Donor Table string DonorMobile = textBoxDonorIDtoDelete.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") { //Database ClassDelete.DeleteDonor(DonorMobile); MessageBox.Show("Success"); buttonShowDonorList_Click(sender, e); } else { MessageBox.Show("ID " + DonorMobile + " Not Found"); } } else { MessageBox.Show("Please Fill Field"); } }
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"); } }
private void buttonShowAdminDGV_Click(object sender, EventArgs e) { //---------------------showing Admin Information in DataGridView string query = "SELECT * FROM AccountTable WHERE Username = '******'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); dataGridViewAdmin.DataSource = dt; buttonShowAdminDGV.Text = "Refresh"; }
private void buttonShowDonorList_Click(object sender, EventArgs e) { //-----------Show Table in DataGridView for Blood Donor string query = "SELECT * FROM DonorTable"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); dataGridViewDonorList.DataSource = dt; buttonShowDonorList.Text = "Refresh"; }
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"); } }
public static string firstStepOfVerification(string username, string password) { string query = "SELECT COUNT (*) FROM AccountTable WHERE Username = '******' AND Password = '******' "; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string trueFalseValue = dt.Rows[0][0].ToString(); return(trueFalseValue); }
private void buttonShowSoldList_Click(object sender, EventArgs e) { //-----------Show Table in DataGridView for Sold List string query = "SELECT * FROM PharmasyTable WHERE TodayStatus= 'Sold' "; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); dataGridViewShowSoldList.DataSource = dt; buttonShowSoldList.Text = "Refresh"; }
public FormShowDrugList(string query) { InitializeComponent(); //-----------Show Table in DataGridView for Blood Donor DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); dataGridViewShowDrugListnForm.DataSource = dt; }
private void buttonDeleteSoldList_Click(object sender, EventArgs e) { //---------------------------------------------Delete Sold Item DialogResult res = MessageBox.Show("Are You Sure To Delete Sold Data ", "Confirmation", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { string query = "UPDATE PharmasyTable SET TodayStatus=' ' ,SoldCopies = '0' WHERE TodayStatus = 'Sold' "; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); buttonShowSoldList_Click(sender, e); } }
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"); } }
private void buttonTotalSoldAmount_Click(object sender, EventArgs e) { //-------------------------------------Get Total Sold Ammount string query = "SELECT SUM(SoldCopies*Price) FROM PharmasyTable WHERE TodayStatus = 'Sold'"; DataTable dt = new DataTable(); ClassCommon.SqlC_DAOpenFillCose(query, dt); string getSum = dt.Rows[0][0].ToString(); if (getSum == "") { MessageBox.Show("Total Sold Amount ::" + 0); } else { int amount = Convert.ToInt16(getSum); MessageBox.Show("Total Sold Amount ::" + amount); } }
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 async Task HandleContextAsync(HttpListenerContext listenerContext) { string rawUrl = listenerContext.Request.RawUrl; HttpListenerRequest request = listenerContext.Request; HttpListenerResponse response = listenerContext.Response; int segmentsCount = request.Url.Segments.Length; // Console.WriteLine("rawUrl: {0} | {1} | {2} | {3}", rawUrl, request.HttpMethod, response, segmentsCount); if (request.HttpMethod == "PUT") { int statusCode; if (new Regex(@"/servers/(\S+)/info(/?$)", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string input = ClassCommon.ShowRequestData(request); string endpoint = request.Url.Segments[segmentsCount - 2].Replace("/", ""); statusCode = AccessData.PutServerInfo(endpoint, input); // Console.WriteLine("input: {0} | endpoint {1} | statusCode {2} ", input, endpoint, statusCode); } else if (new Regex(@"/servers/(\S+)/matches/", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string input = ClassCommon.ShowRequestData(request); string endpoint = request.Url.Segments[segmentsCount - 3].Replace("/", ""); string matchTimestamp = request.Url.Segments[segmentsCount - 1].Replace("/", "").Replace("Z", "").Replace("T", " "); statusCode = AccessData.PutMatchInfo(endpoint, matchTimestamp, input); // Console.WriteLine("input: {0} | {1} | {2}", input, endpoint, matchTimestamp); } else { statusCode = 400; } response.StatusCode = statusCode; // Console.WriteLine("report {0} statusCode= {1}", response.OutputStream, response.StatusCode); using (var writer = new StreamWriter(response.OutputStream)) writer.WriteLine(string.Empty); } else if (request.HttpMethod == "GET") { string responseStr = string.Empty; if (new Regex(@"/servers/(\S+)/matches/", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string endpoint = request.Url.Segments[segmentsCount - 3].Replace("/", ""); string matchTimestamp = request.Url.Segments[segmentsCount - 1].Replace("/", "").Replace("Z", "").Replace("T", " "); responseStr = AccessData.GetMatchInfo(endpoint, matchTimestamp); } else if (new Regex(@"/servers/info(/?$)", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { responseStr = AccessData.GetAllServersInfo(); } else if (new Regex(@"/servers/(\S+)/info(/?$)", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string endpoint = request.Url.Segments[segmentsCount - 2].Replace("/", ""); responseStr = AccessData.GetServerInfo(endpoint); } else if (new Regex(@"/servers/(\S+)/stats(/?$)", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string endpoint = request.Url.Segments[segmentsCount - 2].Replace("/", ""); responseStr = AccessData.GetServerStats(endpoint); } else if (new Regex(@"/players/(\S+)/stats(/?$)", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { string playerName = request.Url.Segments[segmentsCount - 2].Replace("/", ""); responseStr = AccessData.GetPlayerStats(playerName); } else if (new Regex(@"/reports/recent-matches", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { int count; string lastSegment = request.Url.Segments[segmentsCount - 1].Replace("/", "").ToLower(); bool isCorrectCount = ClassCommon.isCorrectCountForReport(lastSegment, "recent-matches", out count); if (isCorrectCount) { responseStr = AccessData.RecentMatches(count); } } else if (new Regex(@"/reports/best-players", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { int count; string lastSegment = request.Url.Segments[segmentsCount - 1].Replace("/", "").ToLower(); bool isCorrectCount = ClassCommon.isCorrectCountForReport(lastSegment, "best-players", out count); if (isCorrectCount) { responseStr = AccessData.BestPlayers(count); } } else if (new Regex(@"/reports/popular-servers", RegexOptions.IgnoreCase).IsMatch(rawUrl)) { int count; string lastSegment = request.Url.Segments[segmentsCount - 1].Replace("/", "").ToLower(); bool isCorrectCount = ClassCommon.isCorrectCountForReport(lastSegment, "popular-servers", out count); if (isCorrectCount) { responseStr = AccessData.PopularServers(count); } } response.StatusCode = (responseStr == string.Empty) ? (int)HttpStatusCode.NotFound : (int)HttpStatusCode.OK; using (var writer = new StreamWriter(response.OutputStream)) await writer.WriteLineAsync(responseStr); } else { response.StatusCode = (int)HttpStatusCode.BadRequest; using (var writer = new StreamWriter(listenerContext.Response.OutputStream)) writer.WriteLine(string.Empty); } }
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"); } }