private void addBtn_Click(object sender, EventArgs e) { { string projname = metroComboBox1.Text; DateTime firstTran = firstTraCompDate.Value; DateTime secondTran = secoTraCompDate.Value; DateTime ins = installDate.Value; DateTime warSt = warStarDate.Value; int warPer = Int32.Parse(warrPerTxt.Text); try { ResoflexClientHandlingSystem.Role.Project project = new Role.Project(projname, firstTran, secondTran, ins, warSt, warPer); Database.updateProject(project); MessageBox.Show("Project Updated Successfully!"); notifyIcon1.Icon = SystemIcons.Application; notifyIcon1.BalloonTipText = "Project Updated!"; notifyIcon1.ShowBalloonTip(1000); } catch (Exception) { MessageBox.Show("Error, Project not Updated!"); } } }
public static void updateProject(ResoflexClientHandlingSystem.Role.Project project) { try { DBConnection.updateDB("UPDATE project SET first_init_date ='" + project.FirstInitDate.ToString("yyyy/MM/d") + "', training_comp_first_end_date='" + project.TEndDate1.ToString("yyyy/MM/d") + "', training_comp_second_end_date='" + project.TEndDate2.ToString("yyyy/MM/dd") + "', warranty_start_date='" + project.WarrantyStart.ToString("yyyy/MM/dd") + "', warranty_period='" + project.WarrantyPeriod + "' WHERE proj_name='" + project.ProjectName + "';"); } catch (Exception exc) { MessageBox.Show("Error" + exc, "Project NOT added", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//added new queries bellow for schedule !! // //-------------------------------------- public static void addProject(ResoflexClientHandlingSystem.Role.Project project) { Client client = project.ClientOfProject; try { DBConnection.updateDB("insert into project (client_id, proj_name, proj_sub_cat_id, proj_cat_id , description, warranty_terms, visit_terms, support_terms)" + " values (" + client.ClientID + ",'" + project.ProjectName + "'," + project.ProjectSubID + "," + project.ProjectCatID + ",'" + project.Projectdesc + "','" + project.WarrantyTerms + "','" + project.VisitTerms + "','" + project.SupportTerms + "')"); } catch (Exception exc) { MessageBox.Show("Error" + exc, "Project NOT added", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void addBtn_Click(object sender, EventArgs e) { try { string name = nameTxt.Text; string description = DescripTxt.Text; string catago = catComboBox.Text.ToString(); string supportTerms = supTermTxt.Text; string visitTerms = visitTermTxt.Text; string warrentyTerms = warTerTxt.Text; Client client; MySqlDataReader reader = DBConnection.getData("select client_id from client where name='" + metroComboBox1.SelectedItem.ToString() + "';"); int cid = 0; while (reader.Read()) { cid = int.Parse(reader.GetValue(0).ToString()); } reader.Close(); client = new Client(cid); try { MySqlDataReader reader3 = DBConnection.getData("select proj_sub_cat_id, proj_cat_id from proj_sub_category where sub_cat_name='" + catComboBox.SelectedItem.ToString() + "'"); if (reader3.Read()) { projSubCatID = Int32.Parse(reader3.GetValue(0).ToString()); projectCatID = Int32.Parse(reader3.GetValue(1).ToString()); } reader3.Close(); } catch (Exception ex) { } ResoflexClientHandlingSystem.Role.Project project = new Role.Project(name, description, client, projSubCatID, projectCatID, supportTerms, visitTerms, warrentyTerms); Database.addProject(project); notifySuccessProjectAdding.Icon = SystemIcons.Application; notifySuccessProjectAdding.BalloonTipText = "Project Successfully Added!"; notifySuccessProjectAdding.ShowBalloonTip(1000); int pid = 0; try { MySqlDataReader reader1 = DBConnection.getData("Select proj_id from project where proj_name='" + project.ProjectName + "'and client_id='" + project.ClientOfProject.ClientID + "';"); while (reader1.Read()) { pid = int.Parse(reader1["proj_id"].ToString()); } reader1.Close(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } UserOperation operation = new UserOperation(new Role.UserLog(Logglobals.id), "Added a new Project", pid); try{ Database.addOp(operation); String email; try { MySqlDataReader reader1 = DBConnection.getData("Select email from client where client_id='" + client.ClientID + "'"); while (reader1.Read()) { email = reader1["email"].ToString(); emailClient(email); } reader1.Close(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Project Updating", MessageBoxButtons.OK, MessageBoxIcon.Error); } }