private void button1_Click(object sender, EventArgs e) { try { ADB = new AppDBLayer(); string name = GridSearchResults.SelectedRows[0].Cells[1].Value.ToString(); ADB.developer.app.setName(name); GridSearchResults.DataSource = null; GridSearchResults.DataSource = ADB.viewFeedback(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void UpdateBTN_Click(object sender, EventArgs e) { if (CheckEmpty(groupBox2) || UpdateAppCB.Text == "") { MessageBox.Show("Fields cannot be left blank"); } else if (!correctUnit(NewSizeUnitCB.Text)) { MessageBox.Show("Size Unit not correct!"); } else if (!correctUnit(NewRAMUnitCB.Text)) { MessageBox.Show("RAM unit not correct!"); } else { decimal size = toKBs(NewSizeTB.Text); decimal ram = toKBs(NewRAMTB.Text); ADB = new AppDBLayer(); ADB.developer.app.setName(UpdateAppCB.Text); ADB.developer.app.dev.setCapacity(size); ADB.developer.app.dev.setRam(ram); ADB.developer.app.setDescription(NewDescriptionTB.Text); ADB.developer.app.setVersion(UpdatedVersionTB.Text); ADB.developer.app.dev.setOS(UpdateOSCB.Text); if (ADB.UpdateApp()) { MessageBox.Show("App Updated Successfully!"); IntializeBoxes(groupBox2); UpdateAppCB.Text = ""; } else { MessageBox.Show("App update Failed!"); } } }
private void RemoveAppBTN_Click(object sender, EventArgs e) { ADB = new AppDBLayer(); if (RemoveAppCB.Text == "") { MessageBox.Show("Please enter App Name!"); } else if (RemoveAppCB.Text == "App Name") { } else { try { ADB.developer.app.setName(RemoveAppCB.Text); if (ADB.RemoveApp()) { MessageBox.Show("App removed Successfully!"); RemoveAppCB.Text = ""; RemoveAppCB.Items.Clear(); AppNamelbl.Text = ""; AppVlbl.Text = ""; AppCatlbl.Text = ""; AppOSlbl.Text = ""; updateCount(); fillCBs(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnCreate_Click(object sender, EventArgs e) { bool result = false; try { if (txtPasswordCreate.Text == txtConfirmCreate.Text) { if (!CheckEmpty()) { if (txtPasswordCreate.TextLength < 8) { MessageBox.Show("Password must be of atLeast 8 Characters"); return; } string input = txtPasswordCreate.Text; bool isDigitPresent = input.Any(a => char.IsDigit(a)); if (!isDigitPresent) { MessageBox.Show("Password must contain atLeast 1 digit"); return; } if (cmbUserType.Text == "Customer") { if (!correctUnit(cmbUnitRam.Text)) { MessageBox.Show("Invlalid Ram Unit"); return; } if (!correctUnit(cmbUnitStr.Text)) { MessageBox.Show("Invlalid Capacity Unit"); return; } customerObj = new CustomerDBLayer(); customerObj.cusObj.setEmail(txtEmailCreate.Text); customerObj.cusObj.setName(txtName.Text); customerObj.cusObj.setGender(cmbGender.Text); customerObj.cusObj.setPswd(txtPasswordCreate.Text); customerObj.cusObj.setCountry(cmbCountry.Text); customerObj.cusObj.device.setName(txtDevName.Text); customerObj.cusObj.device.setOS(txtOS.Text); customerObj.cusObj.device.setRam(Convert.ToDecimal(txtRAM.Text)); customerObj.cusObj.device.setCapacity(Convert.ToDecimal(txtStorage.Text)); result = customerObj.CreateCustomer(cmbUnitRam.Text, cmbUnitStr.Text); } else if (cmbUserType.Text == "Developer") { developerObj = new AppDBLayer(); developerObj.developer.setEmail(txtEmailCreate.Text); developerObj.developer.setName(txtName.Text); developerObj.developer.setGender(cmbGender.Text); developerObj.developer.setPswd(txtPasswordCreate.Text); developerObj.developer.setCountry(cmbCountry.Text); result = developerObj.CreateDeveloper(); } if (result) { MessageBox.Show("Account created successfully"); IntializeBoxes(); } else { MessageBox.Show("Account creation unsuccessful"); } } else { MessageBox.Show("Some of the fields are empty"); } } else { MessageBox.Show("Both Passwords doesn't match"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ShowAppsBTN_Click(object sender, EventArgs e) { GridSearchResults.DataSource = null; ADB = new AppDBLayer(); GridSearchResults.DataSource = ADB.viewApps(id); }
private void UploadBTN_Click(object sender, EventArgs e) { if (CheckEmpty(groupBox1)) { MessageBox.Show("Fields cannot be empty"); } else if (!FreeRB.Checked && !PaidRB.Checked) { MessageBox.Show("Select Free/Paid Option"); } else if (!correctUnit(AppSizeCB.Text)) { MessageBox.Show("Size Unit not correct!"); } else if (!correctUnit(RAMCB.Text)) { MessageBox.Show("RAM unit not correct!"); } else if (PaidRB.Checked && AppCostTB.Text == "") { MessageBox.Show("Please enter cost"); } /*Application1 app = new Application1(); * app.setName(AppNameTB.Text); * app.setCategory(CategoryCB.Text); * app.setDescription(AppDescriptonTB.Text); * app.setVersion(VersionTB.Text); * app.setRating("0.0"); * app.dev.setOS(OSCB.Text); */ else { Device dev = new Device(); decimal size = dev.ConvertToKB(Convert.ToDecimal(AppSizeTB.Text), AppSizeCB.Text); toKBs(AppSizeTB.Text); decimal ram = dev.ConvertToKB(Convert.ToDecimal(RAMTB.Text), RAMCB.Text); String price = "0.0"; if (PaidRB.Checked) { price = AppCostTB.Text; } ADB = new AppDBLayer(); ADB.developer.app.dev.setCapacity(size); ADB.developer.app.dev.setRam(ram); ADB.developer.app.dev.setOS(OSCB.Text); ADB.developer.app.setName(AppNameTB.Text); ADB.developer.app.setCategory(CategoryCB.Text); ADB.developer.app.setDescription(AppDescriptonTB.Text); ADB.developer.app.setVersion(VersionTB.Text); ADB.developer.app.setRating("0.0"); ADB.developer.app.setPrice(Convert.ToDecimal(price)); //if (con.State == ConnectionState.Closed) // con.Open(); //query = "insert into device (OS,RAM,capacity) values('" + OSCB.Text + "',"+Convert.ToString(ram)+"," + Convert.ToString(size) + ")"; //cmd.CommandText = query; //cmd.ExecuteNonQuery(); //String DevID = ""; //int c = 0; //query = "select max(id) as X from Device"; //cmd = new SqlCommand(query, con); //reader = cmd.ExecuteReader(); // while (reader.Read()) // { // c++; // DevID = reader["X"].ToString(); // } // reader.Close(); //query = "Insert into Application Values('" + AppNameTB.Text + "','" + AppDescriptonTB.Text + "','" + VersionTB.Text + "','" + CategoryCB.Text + "','0.0'," + Convert.ToString(id) + "," + price + "," +DevID+",'Yes')"; //cmd.CommandText = query; //cmd.ExecuteNonQuery(); if (ADB.UploadApp(id)) { MessageBox.Show("App Uploaded Successfully"); updateCount(); fillCBs(); IntializeBoxes(groupBox1); } else { MessageBox.Show("App Upload Failed"); } } }