public async Task <IActionResult> PutSDepartment([FromRoute] int id, [FromBody] SDepartment sDepartment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sDepartment.Id)
            {
                return(BadRequest());
            }

            _context.Entry(sDepartment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SDepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public static bool ModifySDepartment(SDepartment department)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;
            int             count = -1;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = MODIFY_SDEPARTMENT_ID_STR;
                cmd.Parameters.AddWithValue("@Id", department.Id);
                cmd.Parameters.AddWithValue("@Name", department.Name);                        // 员工姓名
                cmd.Parameters.AddWithValue("@ShortCall", department.ShortCall);              //  部门简称

                cmd.Parameters.AddWithValue("@CanBoundary", department.CanBoundary);
                cmd.Parameters.AddWithValue("@CanInland", department.CanInland);
                cmd.Parameters.AddWithValue("@CanEmergency", department.CanEmergency);
                cmd.Parameters.AddWithValue("@CanRegular", department.CanRegular);


                count = cmd.ExecuteNonQuery();
                cmd.Dispose();

                con.Close();
                con.Dispose();

                if (count == 1)
                {
                    Console.WriteLine("修改部门信息" + department.Id.ToString() + "成功");

                    return(true);
                }
                else
                {
                    Console.WriteLine("修改部门名称" + department.Id.ToString() + "失败");

                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
        public async Task <IActionResult> PostSDepartment([FromBody] SDepartment sDepartment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SDepartment.Add(sDepartment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSDepartment", new { id = sDepartment.Id }, sDepartment));
        }
Beispiel #4
0
        public static List <SDepartment> QuerySDepartment()
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            List <SDepartment> departments = new List <SDepartment>();

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = QUERY_SDEPARTMENT_STR;

                MySqlDataReader sqlRead = cmd.ExecuteReader();
                cmd.Dispose();

                while (sqlRead.Read())
                {
                    SDepartment department = new SDepartment();

                    department.Id        = int.Parse(sqlRead["id"].ToString());
                    department.Name      = sqlRead["name"].ToString();
                    department.ShortCall = sqlRead["shortcall"].ToString();

                    department.CanBoundary  = int.Parse(sqlRead["canboundary"].ToString());
                    department.CanInland    = int.Parse(sqlRead["caninland"].ToString());
                    department.CanEmergency = int.Parse(sqlRead["canemergency"].ToString());
                    department.CanRegular   = int.Parse(sqlRead["canregular"].ToString());


                    departments.Add(department);
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(departments);
        }
Beispiel #5
0
      public void GetDepartment()
      {
          DataSet ds = DIMERCO.SDK.Utilities.LSDK.getCRPDepartment();
          //SqlConnection cn = new SqlConnection("Data Source=10.130.40.20;Initial Catalog=ReSM;User ID=sa;Password=dim1rc0@");
          //SqlDataAdapter da = new SqlDataAdapter("select distinct departmentname from  SMDepartment", cn);
          //DataSet ds = new DataSet();
          //da.Fill(ds);
          DataTable tb = ds.Tables[0];

          SDepartment.DataSource = tb;
          SDepartment.DataBind();
          ds.Dispose();
      }
Beispiel #6
0
        public static bool InsertSDepartment(SDepartment department)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();

            MySqlCommand cmd;
            int          count = -1;             // 受影响行数

            try
            {
                con.Open();

                cmd             = con.CreateCommand();
                cmd.CommandText = INSERT_SDEPARTMENT_STR;
                cmd.Parameters.AddWithValue("@Name", department.Name);                  //  部门职位
                cmd.Parameters.AddWithValue("@ShortCall", department.ShortCall);        //  部门简称

                cmd.Parameters.AddWithValue("@CanBoundary", department.CanBoundary);
                cmd.Parameters.AddWithValue("@CanInland", department.CanInland);
                cmd.Parameters.AddWithValue("@CanEmergency", department.CanEmergency);
                cmd.Parameters.AddWithValue("@CanRegular", department.CanRegular);

                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();
                }
            }
        }
Beispiel #7
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 5)         //  修改当前部门信息
            {
                if (MessageBox.Show("确定要修改当前部门信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    SDepartment    sdepartment = UserHelper.SDepList[e.RowIndex];
                    EditDepartment ed          = new EditDepartment(sdepartment, _sc);
                    ed.ShowDialog();
                    if (ed.DialogResult == DialogResult.OK)
                    {
                        BindGridViewDataSourece();          //  绑定部门源

                        BindEmployee(0);                    //  绑定员工信息
                    }
                }
            }
            else if (e.ColumnIndex == 6)         //  删除当前部门信息
            {
                if (MessageBox.Show("确定要删除此部门?\n危险操作,请谨慎进行\n由于部门下面可能有员工,因此您的删除操作会将部门下的所有员工全部被删除,由此将引入很多不安全问题,请问您是否继续删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int    Id     = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex].Cells[4].Value);
                    string result = _sc.DeleteDepartment(Id);

                    if (result == Response.DELETE_DEPARTMENT_SUCCESS.ToString())
                    {
                        MessageBox.Show("删除部门成功!", "提示", MessageBoxButtons.OK);
                        BindGridViewDataSourece();
                        BindEmployee(0);                    //  绑定员工信息
                    }
                    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);
                    }
                }
            }
        }
Beispiel #8
0
        public static bool SetSDepartmentInland(SDepartment department)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;
            int             count;

            try
            {
                con.Open();

                cmd             = con.CreateCommand();
                cmd.CommandText = SET_SDEPARTMENT_INLAND_STR;
                cmd.Parameters.AddWithValue("@CanInland", department.CanInland);

                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();
                }
            }
        }
Beispiel #9
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            /// modify by gatieme at 2015-09-10 13:47
            ///
            //MessageBox.Show("单击了第" + e.RowIndex.ToString() + "行" + e.ColumnIndex.ToString() + "列", "提示", MessageBoxButtons.OK);
            ///

            //if (e.RowIndex < 0)
            //{
            //    return;
            //}


            //if (e.ColumnIndex >= 0 && e.ColumnIndex <= 3)
            //{
            //    /// 首先取出底层数据中对应的数据项

            //    SDepartment sdepartment = UserHelper.SDepList[e.RowIndex];

            //    if (e.ColumnIndex == 0)             //  可以申请界河项目
            //    {
            //        sdepartment.CanBoundary = ((sdepartment.CanBoundary == "是") ? "否" : "是");
            //    }
            //    else if (e.ColumnIndex == 1)        //  可以申请内河项目
            //    {
            //        sdepartment.CanInland = ((sdepartment.CanInland == "是") ? "否" : "是");
            //    }
            //    else if (e.ColumnIndex == 2)        //  可以申请应急抢修项目
            //    {
            //        sdepartment.CanEmergency = ((sdepartment.CanEmergency == "是") ? "否" : "是");
            //    }
            //    else if (e.ColumnIndex == 3)        //  可以申请例会项目
            //    {
            //        sdepartment.CanRegular = ((sdepartment.CanRegular == "是") ? "否" : "是");
            //    }

            //    string result = _sc.ModifySDepartment(sdepartment);

            //    if (result == Response.MODIFY_SDEPARTMENT_SUCCESS.ToString())
            //    {
            //        MessageBox.Show("修改部门权限成功!", "提示", MessageBoxButtons.OK);
            //        BindGridViewDataSourece();
            //        BindEmployee(0);                    //  绑定员工信息

            //    }
            //    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);
            //    }

            //}
            if (e.ColumnIndex == 7)         //  修改当前部门信息
            {
                if (MessageBox.Show("确定要修改当前部门信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    SDepartment    sdepartment = UserHelper.SDepList[e.RowIndex];
                    EditDepartment ed          = new EditDepartment(sdepartment, _sc);
                    ed.ShowDialog();
                    if (ed.DialogResult == DialogResult.OK)
                    {
                        BindGridViewDataSourece();          //  绑定部门源

                        BindEmployee(0);                    //  绑定员工信息
                    }
                }
            }
            else if (e.ColumnIndex == 8)         //  删除当前部门信息
            {
                if (MessageBox.Show("确定要删除此部门?\n危险操作,请谨慎进行\n由于部门下面可能有员工,因此您的删除操作会将部门下的所有员工全部被删除,由此将引入很多不安全问题,请问您是否继续删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int    Id     = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex].Cells[4].Value);
                    string result = _sc.DeleteDepartment(Id);

                    if (result == Response.DELETE_DEPARTMENT_SUCCESS.ToString())
                    {
                        MessageBox.Show("删除部门成功!", "提示", MessageBoxButtons.OK);
                        BindGridViewDataSourece();
                        BindEmployee(0);                    //  绑定员工信息
                    }
                    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);
                    }
                }
            }
        }
Beispiel #10
0
        private void AddDepartment_Click(object sender, EventArgs e)                  //添加部门
        {
            //  modify by gatieme at 2015-08-08 16:20
            //  为部门添加部门简称
            string departmentName      = this.DepartmentName.Text.Trim();
            string departmentShortCall = this.textBoxDepartmentShortCall.Text.Trim();

            if (departmentName == "")
            {
                MessageBox.Show("请填写部门名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (departmentShortCall == "")
            {
                MessageBox.Show("请填写部门简称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (UserHelper.DepList.Where(o => o.Name == departmentName).ToList().Count > 0)
            {
                MessageBox.Show("该部门的部门名称与其他部门重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (UserHelper.DepList.Where(o => o.ShortCall == departmentShortCall).ToList().Count > 0)
            {
                MessageBox.Show("该部门的部门简称与其他部门重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            Department department = new Department {
                Id = -1, Name = departmentName, ShortCall = departmentShortCall
            };
            SDepartment sdepartment = new SDepartment();

            sdepartment.Id        = -1;
            sdepartment.Name      = departmentName;
            sdepartment.ShortCall = departmentShortCall;
            if (this.CanBoundary.Checked)
            {
                sdepartment.CanBoundary = 1;
            }
            else
            {
                sdepartment.CanBoundary = 0;
            }

            if (this.CanInLand.Checked)
            {
                sdepartment.CanInland = 1;
            }
            else
            {
                sdepartment.CanInland = 0;
            }

            if (this.CanEmergency.Checked)
            {
                sdepartment.CanEmergency = 1;
            }
            else
            {
                sdepartment.CanEmergency = 0;
            }

            if (this.CanRegular.Checked)
            {
                sdepartment.CanRegular = 1;
            }
            else
            {
                sdepartment.CanRegular = 0;
            }

            //string result = _sc.InsertDepartment(department);
            string result = _sc.InsertSDepartment(sdepartment);

            //if (result == Response.INSERT_DEPARTMENT_SUCCESS.ToString())
            //{
            if (result == Response.INSERT_SDEPARTMENT_SUCCESS.ToString())
            {
                MessageBox.Show("添加" + departmentName + "部门成功!");

                ///////
                BindGridViewDataSourece();
                ///////
            }
            //}
            else
            {
                MessageBox.Show("添加" + departmentName + "部门失败!");
            }
        }
Beispiel #11
0
 public EditDepartment(SDepartment sdepartment, SignSocketClient sc)
     : this()
 {
     this.m_sdepartment = sdepartment;
     this._sc           = sc;
 }