示例#1
0
        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 + "失败!");
            }
        }
        public string ModifyProject(ContractProject project)
        {
            try
            {
                SocketMessage sm = new SocketMessage(Request.MODIFY_PROJECT_REQUEST, project);
                //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.MODIFY_PROJECT_SUCCESS.ToString())
                {
                    Logging.AddLog("修改项目" + project.Project + "成功!");
                }
                else
                {
                    Logging.AddLog("修改项目" + project.Project + "失败!");
                }
                return Msg[0];
            }
            catch
            {
                Logging.AddLog("添加工作量失败(服务器连接中断)!");
                return "添加失败";
            }

        }