public EditProject(string categoryName, ContractProject project, SignSocketClient sc) : this() { this.m_categoryName = categoryName; this.m_project = project; _sc = sc; }
public static ContractWorkload StatisYearProjectRegularLoad(int year, ContractProject project) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; ContractWorkload workload = null; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = STATIS_YEAR_PROJECT_REGULARLOAD_STR; cmd.Parameters.AddWithValue("@Year", year); cmd.Parameters.AddWithValue("@ProjectId", project.Id); MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { workload = new ContractWorkload(); workload.ContractId = STATIS_KIND.STATIS_YEAR_PROJECT_REGULARLOAD.ToString(); workload.Work = double.Parse(sqlRead["works"].ToString()); workload.Expense = double.Parse(sqlRead["expenses"].ToString()); /// BUG ContractItem item = new ContractItem(); item.Id = -1; workload.Item = item; } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(workload); }
public static bool CheckIntegrity(ContractProject project) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int count = -1; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = CHECK_PROJECT_INTEGRITY_STR; cmd.Parameters.AddWithValue("@Id", project.Id); cmd.Parameters.AddWithValue("@Project", project.Project); MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { count = int.Parse(sqlRead["count"].ToString()); } con.Close(); con.Dispose(); if (count == 1) { return(true); } else { Console.WriteLine("PROJECT : Id = {0}, Project = {1}检查失败", project.Id, project.Project); return(false); } } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 2) // 修改当前部门信息 { if (MessageBox.Show("确定要修改当前项目类别信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // BUG string categoryName = ((ComboboxItem)this.SelectedCategory.SelectedItem).Text; ContractProject project = UserHelper.ContractProjectList[e.RowIndex]; EditProject ep = new EditProject(categoryName, project, _sc); ep.ShowDialog(); if (ep.DialogResult == DialogResult.OK) { this.BindProject(true); } } } else if (e.ColumnIndex == 3) // 删除当前部门信息 { if (MessageBox.Show("确定要删除此项目类别信息?\n危险操作,请谨慎进行\n由于此项目类别下面可能有工作量集合,因此您的删除操作会将此项目下的所有工作量全部被删除,由此将引入很多不安全问题,请问您是否继续删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //MessageBox.Show(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value.ToString()); int projectId = Convert.ToInt32(this.dataGridView3.Rows[e.RowIndex].Cells[0].Value); string result = _sc.DeleteProject(projectId); if (result == Response.DELETE_PROJECT_SUCCESS.ToString()) { MessageBox.Show("删除项目类别成功!", "提示", MessageBoxButtons.OK); BindProject(true); } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } //else if (result == Response.DELETE_DEPARTMENT_EXIST_EMPLOYEE.ToString()) //{ // MessageBox.Show("该部门下有人员存在,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} else { MessageBox.Show("删除项目类别失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
/// <summary> /// 插入部门信息 /// </summary> /// <param name="employee"></param> /// <returns></returns> public static bool InsertContractProject(ContractProject project) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int count = -1; // 受影响行数 try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = INSERT_CONTRACT_PROJECT_STR; cmd.Parameters.AddWithValue("@CategoryId", project.CategoryId); // 项目类型 cmd.Parameters.AddWithValue("@Project", project.Project); // 项目类型简写 count = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); con.Dispose(); if (count == 1) // 插入成功后的受影响行数为1 { Console.WriteLine("插入项目类型成功"); return(true); } else { Console.WriteLine("插入项目类型失败"); return(false); } } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
public static List <ContractProject> QueryCategoryProject(int categoryId) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; List <ContractProject> projects = new List <ContractProject>(); try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = QUERY_CATEGORY_PROJECT_BY_ID_STR; cmd.Parameters.AddWithValue("@CategoryId", categoryId); MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { ContractProject project = new ContractProject(); project.Id = int.Parse(sqlRead["id"].ToString()); project.CategoryId = int.Parse(sqlRead["categoryid"].ToString()); project.Project = sqlRead["project"].ToString(); projects.Add(project); } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(projects); }
public static bool ModifyProject(ContractProject project) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int count = -1; // 受影响行数 try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = MODIFY_PROJECT_STR; cmd.Parameters.AddWithValue("@Id", project.Id); // 部门职位 cmd.Parameters.AddWithValue("@CategoryId", project.CategoryId); cmd.Parameters.AddWithValue("@Project", project.Project); count = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); con.Dispose(); if (count == 1) // 插入成功后的受影响行数为1 { Console.WriteLine("工程类别{0}修改成功", project.Project); return(true); } else { Console.WriteLine("工程类别{0}修改失败", project.Project); return(false); } } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
public static int GetProjectId(String categoryName) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int id = -1; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = GET_PROJECT_ID_BY_NAME_STR; cmd.Parameters.AddWithValue("@CategoryName", categoryName); MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { ContractProject project = new ContractProject(); id = int.Parse(sqlRead["id"].ToString()); } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(id); }
private void buttonAddProject_Click(object sender, EventArgs e) { if (this.SelectedCategory.SelectedItem == null) { MessageBox.Show("请填写完整的工作量名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string projectname = this.pName.Text; //int categoryId = Convert.ToInt32(this.SelectedCategory.SelectedValue); int categoryId = int.Parse(((ComboboxItem)this.SelectedCategory.SelectedItem).Value); if (projectname == "") { MessageBox.Show("请填写工作量名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ContractProject project = new ContractProject { CategoryId = categoryId, Project = projectname, }; string result = _sc.InsertProject(project); if (result == Response.INSERT_PROJECT_SUCCESS.ToString()) { MessageBox.Show("添加项目" + project.Project + "成功!"); ///////////////////////////////////////// BindProject(true); /////////////////////////////////////// } else { MessageBox.Show("添加项目" + project.Project + "失败!"); } }
private void buttonModify_Click(object sender, EventArgs e) { string projectName = this.textBoxProjectName.Text.Trim(); if (projectName == "") { MessageBox.Show("请将工作量信息填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (projectName == this.m_project.Project) { MessageBox.Show("你未修改任何信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.m_project.Project = projectName; try { string result = _sc.ModifyProject(this.m_project); if (result == Response.MODIFY_PROJECT_SUCCESS.ToString()) { MessageBox.Show("修改工作量信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,修改员工信息失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("修改工作量信息失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public static ContractWorkload StatisHSDepartmentYearProjectWorkLoad(HSDepartment department, int year, ContractProject project) { if (department.IsHigherDepatmentHasSub() == true) // 如果当前部门是一个有下属部门的一级部门 { //Console.WriteLine("部门{0}是一个有子部门的一级部门", department.Name); return(DALContractStatistic.StatisHigherDepartmentYearProjectWorkLoad(department, year, project)); } else if (department.IsHigherDepatmentNoSub() == true) { //Console.WriteLine("部门{0}是无子部门的一级部门", department.Name); return(DALContractStatistic.StatisDepartmentYearProjectWorkLoad(department, year, project)); } else if (department.IsStatisTotalDepartment() == true) { //Console.WriteLine("部门{0}要求统计所有部门的总和", department.Name); return(DALContractStatistic.StatisYearProjectWorkLoad(year, project)); } else if (department.IsStatisRegularDepartment() == true) { //Console.WriteLine("部门{0}要求统计计划任务额度", department.Name); return(DALContractStatistic.StatisYearProjectRegularLoad(year, project)); } else if (department.IsSubDepartment() == true) // 如果当前部门是一个下属子部门 { //Console.WriteLine("部门{0}是下属子部门", department.Name); return(null); } return(null); }
public static ContractWorkload StatisHigherDepartmentYearProjectWorkLoad(HSDepartment highDepartment, int year, ContractProject project) { // 首先获取到当前一级部门的所有下级部门信息 List <HSDepartment> departments = DALHSDepartment.QuerySubHSDepartment(highDepartment.Id); ContractWorkload totalWorkloads = new ContractWorkload { Work = 0, Expense = 0, }; foreach (HSDepartment department in departments) { ContractWorkload workload = DALContractStatistic.StatisDepartmentYearProjectWorkLoad(department, year, project); totalWorkloads.Work += workload.Work; totalWorkloads.Expense += workload.Expense; } return(totalWorkloads); }
/// <summary> /// 统计当前部门申请的所有工程Project下的会签单信息[Search数据填写SDepartmentShortCall + ItemId] /// </summary> /// <param name="search"></param> /// <returns></returns> public static ContractWorkload StatisDepartmentYearProjectWorkLoad(HSDepartment department, int year, ContractProject project) { if (project.Id == 10) { } MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; ContractWorkload workload = null; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = STATIS_DEPARTMENT_YEAR_PROJECT_STR; cmd.Parameters.AddWithValue("@SDepartmentYear", department.ShortCall + "__" + year.ToString() + "%"); cmd.Parameters.AddWithValue("@ProjectId", project.Id); MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { workload = new ContractWorkload(); workload.ContractId = STATIS_KIND.STATIS_DEPARTMENT_YEAR_PROJECT_WORKLOAD.ToString(); workload.Work = double.Parse(sqlRead["works"].ToString()); workload.Expense = double.Parse(sqlRead["expenses"].ToString()); ContractItem item = new ContractItem(); item.Id = -1; workload.Item = item; } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(workload); }