コード例 #1
0
        /// <summary>
        /// 修改PathEmpRelation信息
        /// </summary>
        /// <returns>返回操作结果 1表示成功</returns>
        private int UpdatePathEmpRelation()
        {
            try
            {
                //存入日志
                LogSave.Messages("[FrmPathEmp]", LogIDType.UserLogID, "修改员工路径关系信息,路线编号:"
                                 + this.tbPathNo.Text + ",员工姓名:" + this.cbEmp.SelectedText.ToString() + "。");

                KJ128NModel.PathEmpRelationModel model = new PathEmpRelationModel();
                model.Id = Convert.ToInt32(dgvMain.CurrentRow.Cells["Id"].Value.ToString());

                if (this.cbEmp.SelectedValue != null)
                {
                    model.EmpID = Convert.ToInt32(this.cbEmp.SelectedValue.ToString());
                }
                else
                {
                    MessageBox.Show("修改员工信息不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(0);
                }
                model.PathNo = this.tbPathNo.Text;
                string strMessage = "";
                int    count      = pathEmpRelationbll.UpdatePathEmpRelation(model, out strMessage);

                bool flag = (count == 1 ? true : false);

                if (flag)
                {
                    this.vspnlAdd.Visible = false;
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(0);
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Check())
            {
                PathEmpRelationModel pathEmpModel = new PathEmpRelationModel();
                pathEmpModel.PathNo = cmbPathID.Text;
                pathEmpModel.EmpID  = int.Parse(cmbEmp.SelectedValue.ToString());
                string strMessage = "";
                int    rowCount   = 0;
                switch (m_type)
                {
                case 1:    //添加
                    try
                    {
                        rowCount = pathEmpBll.InsertPathEmpRelation(pathEmpModel, out strMessage);
                        if (strMessage.Equals("Succeeds"))
                        {
                            if (rowCount > 0)
                            {
                                SetShowInfo("保存成功", Color.Black);
                            }
                            else
                            {
                                SetShowInfo("添加重复数据", Color.Red);
                                return;
                            }
                        }
                        else
                        {
                            SetShowInfo("保存失败", Color.Red);
                            return;
                        }
                    }
                    catch
                    {
                        SetShowInfo("保存失败", Color.Red);
                        return;
                    }

                    break;

                case 2:    //修改
                    pathEmpModel.Id = int.Parse(txtID.Text);
                    try
                    {
                        pathEmpBll.UpdatePathEmpRelation(pathEmpModel, out strMessage);
                        if (strMessage.Equals("Succeeds"))
                        {
                            SetShowInfo("修改成功", Color.Black);
                        }
                        else
                        {
                            SetShowInfo("修改失败", Color.Red);
                            return;
                        }
                    }
                    catch
                    {
                        SetShowInfo("修改失败", Color.Red);
                        return;
                    }
                    break;
                }
                if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                {
                    m_frmPathManage.SetTreeViewPathEmp();
                    m_frmPathManage.BindData("");
                }
                else                                //热备版,启用定时器
                {
                    m_frmPathManage.HostBackRefresh(true);
                }
            }
        }