示例#1
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);
                }
            }
        }