Ejemplo n.º 1
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 + "部门失败!");
            }

        }
Ejemplo n.º 2
0
         public String ModifySDepartment(SDepartment department)
         {
             //return Task.Factory.StartNew(() =>
             {
                 try
                 {
                     SocketMessage sm = new SocketMessage(Request.MODIFY_SDEPARTMENT_REQUEST, department);
                     ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                     recLength = ClientSocket.Receive(recivebuffer);
                     string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);

                     string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                     if (Msg[0] == Response.MODIFY_SDEPARTMENT_SUCCESS.ToString())
                     {

                         Logging.AddLog("修改部门成功");
                     }
                     else
                     {
                         Logging.AddLog("修改部门失败!");
                     }
                     return Msg[0];
                 }
                 catch
                 {
                     Logging.AddLog("重置用户密码失败(服务器连接中断)!");
                     return "服务器连接中断";
                 }
                 //});
             }
         }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加部门权限
        /// </summary>
        /// <param name="sdepartment"></param>
        /// <returns></returns>
        public string InsertSDepartment(SDepartment sdepartment)
        {
            try
            {
                SocketMessage sm = new SocketMessage(Request.INSERT_SDEPARTMENT_REQUEST, sdepartment);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.INSERT_SDEPARTMENT_SUCCESS.ToString())
                {
                    Logging.AddLog("添加部门权限成功!");
                }
                else
                {
                    Logging.AddLog("添加部门权限失败!");
                }
                return Msg[0];
            }
            catch
            {
                Logging.AddLog("添加部门权限失败(服务器连接中断)!");
                return "添加失败";
            }
        }
Ejemplo n.º 4
0
 public EditDepartment(SDepartment sdepartment, SignSocketClient sc)
     : this()
 {
     this.m_sdepartment = sdepartment;
     this._sc = sc;
 }