using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Pur.configure; using Pur.Entity; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Control; using Pur.Entity.configureEntity; using System.Collections; using com.hnshituo.pur.vo; using Core.Mes.Client.Comm.Tool; using Pur.require_plan; using Infragistics.Win.UltraWinTree; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; namespace Pur.pur_plan { public partial class frmPopConfEvaUser : FrmPmsBase { public frmPopConfEvaUser() { InitializeComponent(); } //菜单按钮事件 public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": Query(); break; case "Add": confirm(); break; case "Update": Update(); break; case "Delete": Delete(); break; } } /// /// 选择评标人员 /// /// /// private void txt_EVA_USERNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (ultraTree1.ActiveNode != null) { SetectManByDept frm = new SetectManByDept(this.ob, this.UserInfo.GetDeptid()); frm.ShowDialog(); txt_EVA_ORG_ID.Text = frm.StrDeptId; txt_EVA_ORG_NAME.Text = frm.StrDeptName; txt_EVA_USERID.Text = frm.StrUserID; txt_EVA_USERNAME.Text = frm.StrUserName; } } //刷新角色信息 private void Query() { getSelEvaRole(); } /// /// 添加 /// private void confirm() { if (ultraTree1.ActiveNode != null) { //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key) //{ // if (MessageUtil.ShowYesNoAndTips("当前所选评标人员所在科室【" + txt_EVA_ORG_NAME.Text + "】不为左侧树形结构所选科室,是否确定添加?").Equals(DialogResult.No)) // { // return; // } //} if (string.IsNullOrEmpty(txt_EVA_ORG_ID.Text)) { MessageUtil.ShowTips("请选择人员"); return; } if (string.IsNullOrEmpty(cmb_EVA_ROLE_NAME.Text)) { MessageUtil.ShowTips("请选择角色"); return; } PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity(); ConfEvaUserEntity.EvaGroupId = ultraTree1.ActiveNode.Key; ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id ConfEvaUserEntity.Validflag = "1"; if (isExsitRow("com.hnshituo.pur.purplan.service.ConfEvaUserService", ConfEvaUserEntity)>0) { MessageUtil.ShowTips("所选评标人员分组存在相同用户,不能重复添加"); return; } string strId = this.execute("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_CONF_EVA_USER", "ID", ultraTree1.ActiveNode.Key, "3" }); ConfEvaUserEntity.Id = strId; ConfEvaUserEntity.CreateName = UserInfo.GetUserName(); ConfEvaUserEntity.CreateUserId = UserInfo.GetUserID(); ConfEvaUserEntity.CreateTime = System.DateTime.Now; ConfEvaUserEntity.EvaRoleId = cmb_EVA_ROLE_NAME.Value.ToString();//角色Id ConfEvaUserEntity.EvaRoleName = cmb_EVA_ROLE_NAME.Text;//角色名称 ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id ConfEvaUserEntity.EvaUsername = txt_EVA_USERNAME.Text;//用户名称 ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id ConfEvaUserEntity.EvaOrgName = txt_EVA_ORG_NAME.Text;//科室名称 ConfEvaUserEntity.Validflag = "1"; CoreResult crt = this.execute("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doInsert", new object[] { ConfEvaUserEntity }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("添加失败 " + crt.Resultmsg); return; } MessageUtil.ShowTips("添加成功"); //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key) //{ // getSelEvaRole();//查询评标人员科室 // UltraTreeNode utnd = ultraTree1.GetNodeByKey(txt_EVA_ORG_ID.Text); // ultraTree1.ActiveNode = utnd; // getSelEvaUsers(ultraTree1.ActiveNode.Key); // comm.doActiveSelRow(ultraGrid2, "ID", strId); //} //else //{ getSelEvaUsers(ultraTree1.ActiveNode.Key); comm.doActiveSelRow(ultraGrid2, "ID", strId); //} } } /// /// 修改 /// private void Update() { if (ultraGrid2.ActiveRow == null) { return; } if (string.IsNullOrEmpty(txt_EVA_ORG_ID.Text)) { MessageUtil.ShowTips("请选择人员"); return; } if (string.IsNullOrEmpty(cmb_EVA_ROLE_NAME.Text)) { MessageUtil.ShowTips("请选择角色"); return; } PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity(); ConfEvaUserEntity.EvaGroupId = ultraTree1.ActiveNode.Key; //ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id //ConfEvaUserEntity.EvaRoleId = cmb_EVA_ROLE_NAME.Value.ToString();//角色Id ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id ConfEvaUserEntity.Validflag = "1"; if (txt_EVA_USERID.Text != ultraGrid2.ActiveRow.Cells["EVAUSERID"].Value.ToString()) { if (isExsitRow("com.hnshituo.pur.purplan.service.ConfEvaUserService", ConfEvaUserEntity) > 0) { MessageUtil.ShowTips("所选评标人员分组存在相同用户,不能修改"); return; } } //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key) //{ // if (MessageUtil.ShowYesNoAndTips("当前所选评标人员所在科室【" + txt_EVA_ORG_NAME.Text + "】不为左侧树形结构所选科室,是否确定添加?").Equals(DialogResult.No)) // { // return; // } //} ConfEvaUserEntity.Id = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString(); ConfEvaUserEntity.UpdateName = UserInfo.GetUserName(); ConfEvaUserEntity.UpdateUserId = UserInfo.GetUserID(); ConfEvaUserEntity.UpdateTime = System.DateTime.Now; ConfEvaUserEntity.EvaRoleName = cmb_EVA_ROLE_NAME.Text;//角色名称 ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id ConfEvaUserEntity.EvaUsername = txt_EVA_USERNAME.Text;//用户名称 ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id ConfEvaUserEntity.EvaOrgName = txt_EVA_ORG_NAME.Text;//科室名称 ConfEvaUserEntity.Validflag = "1"; if (MessageUtil.ShowYesNoAndQuestion("确定修改?") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doUpdate", new object[] { ConfEvaUserEntity }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("修改失败 " + crt.Resultmsg); return; } MessageUtil.ShowTips("修改成功"); //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key) //{ // getSelEvaRole();//查询评标人员科室 // UltraTreeNode utnd = ultraTree1.GetNodeByKey(txt_EVA_ORG_ID.Text); // ultraTree1.ActiveNode = utnd; // getSelEvaUsers(ultraTree1.ActiveNode.Key); // comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id); //} //else //{ getSelEvaUsers(ultraTree1.ActiveNode.Key); comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id); //} } /// /// 删除 /// private void Delete() { if (ultraGrid2.ActiveRow == null) { return; } PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity(); ConfEvaUserEntity.Id = ultraGrid2.ActiveRow.Cells["Id"].Value.ToString(); ConfEvaUserEntity.Validflag = "0"; ConfEvaUserEntity.DeleteName = UserInfo.GetUserName(); ConfEvaUserEntity.DeleteUserId = UserInfo.GetUserID(); ConfEvaUserEntity.DeleteTime = System.DateTime.Now; if (MessageUtil.ShowYesNoAndQuestion("确定删除?") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doUpdate", new object[] { ConfEvaUserEntity }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("删除失败 " + crt.Resultmsg); return; } MessageUtil.ShowTips("删除成功"); getSelEvaUsers(ultraTree1.ActiveNode.Key); comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id); } /// /// 选择节点 /// /// /// private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e) { if (ultraTree1.ActiveNode != null) { getSelEvaUsers(ultraTree1.ActiveNode.Key); } } /// /// 查询选择评标人员角色信息 /// private void getSelEvaUsers(string strEvaGroupId) { //PurTaskEvaUsersEntity TaskEvaUsersEntity = new PurTaskEvaUsersEntity(); PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity(); ConfEvaUserEntity.EvaGroupId = strEvaGroupId; ConfEvaUserEntity.Validflag = "1"; DataTable dt = this.execute("com.hnshituo.pur.purplan.service.ConfEvaUserService", "find", new object[] { ConfEvaUserEntity, 0, 0 }); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); GridHelper.RefreshAndAutoSize(ultraGrid2); ConfigureClassCommon.clearOldData(txt_EVA_ORG_ID.Parent); } /// /// 查询评标人员分组 /// private void getSelEvaRole() { ultraTree1.Nodes.Clear(); //评标人员科室 //DataTable dt = this.execute("com.hnshituo.pur.purplan.service.ConfEvaUserService", "getConfEvaUser", new object[] { }); //for (int i = 0; i < dt.Rows.Count; i++) //{ // ultraTree1.Nodes.Add(dt.Rows[i]["evaorgid"].ToString(), dt.Rows[i]["evaorgname"].ToString()); //} //评标人员分组 DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1227" }, this.ob); for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["Validflag"].ToString() == "1") { ultraTree1.Nodes.Add(dt.Rows[j]["BASECODE"].ToString(), dt.Rows[j]["BASENAME"].ToString()); } } } private void frmPopConfEvaUser_Load(object sender, EventArgs e) { //评标人员角色 DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1224" }, this.ob); dt.DefaultView.RowFilter = "Validflag='1'"; dt = dt.DefaultView.ToTable(); cmb_EVA_ROLE_NAME.DataSource = dt; cmb_EVA_ROLE_NAME.DisplayMember = "BASENAME"; cmb_EVA_ROLE_NAME.ValueMember = "BASECODE"; getSelEvaRole(); } /// /// 绑定所有的下拉列表的数据 /// private void getUltcmbBindValueList(DataTable dt, UltraComboEditor ultcmb) { for (int i = 0; i < dt.Rows.Count; i++) { ValueListItem vlItem = new ValueListItem(dt.Rows[i]["BASECODE"].ToString().Trim(), dt.Rows[i]["BASENAME"].ToString().Trim()); ultcmb.Items.Add(vlItem); } } /// /// 移除无效数据 /// /// private void removeNotValiflagData(DataTable dt) { for (int i = 0; i < dt.Rows.Count; ) { if (dt.Rows[i]["VALIDFLAG"].ToString() == "0") { dt.Rows.RemoveAt(i); } else { i++; } } } /// /// 绑定下拉列表的数据 /// /// /// private void getUltcmbBindData() { DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob); removeNotValiflagData(dt); getUltcmbBindValueList(dt, cmb_EVA_ROLE_NAME); } /// /// 判断数据库中是否存在相同的列 /// /// /// /// true存在 public int isExsitRow(string strJavaPackName, object o) { DataTable dt = this.execute(strJavaPackName, "find", new object[] { o, 0, 0 }); if (dt != null && dt.Rows.Count > 0)//存在相同的行 { return dt.Rows.Count; } return 0; } /// /// 激活grid传值给控件 /// /// /// private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { cmb_EVA_ROLE_NAME.Text = ultraGrid2.ActiveRow.Cells["EVAROLENAME"].Value.ToString();//角色名称 txt_EVA_ORG_ID.Text = ultraGrid2.ActiveRow.Cells["EVAORGID"].Value.ToString();//科室Id txt_EVA_USERID.Text = ultraGrid2.ActiveRow.Cells["EVAUSERID"].Value.ToString();//用户Id txt_EVA_USERNAME.Text = ultraGrid2.ActiveRow.Cells["EVAUSERNAME"].Value.ToString();//用户名称 txt_EVA_ORG_NAME.Text = ultraGrid2.ActiveRow.Cells["EVAORGNAME"].Value.ToString();//科室名称 } } }