/// <summary> /// 查询历史记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnScan_Click(object sender, EventArgs e) { try { if (checkEdit1.Checked) { // 根据发放设置查询条件,进行查询 doc_grant_setting doc_grant_setting = new doc_grant_setting(); doc_grant_setting.grant_user = this.textEdit1.Text; doc_grant_setting.grant_user = this.textEdit2.Text; doc_grant_setting.valid_time = this.textEdit7.Text; grantSettingList = WcfServiceLocator.Create<IDocGrantManage>().getGrantSetting(doc_grant_setting); dgcGrant.DataSource = grantSettingList; } else { // 根据文档查询条件,进行查询 document doc = new document(); doc.number = this.textEdit3.Text; doc.version = this.textEdit4.Text; doc.cn_name = this.textEdit5.Text; doc.create_user_name = this.textEdit6.Text; grantSettingList = WcfServiceLocator.Create<IDocGrantManage>().getGrantSettingByDoc(doc); dgcGrant.DataSource = grantSettingList; } dgcGrant.RefreshDataSource(); } catch (Exception ex) { } }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (docGrantSetting == null) { docGrantSetting = new doc_grant_setting(); } // 权限天数 docGrantSetting.valid = this.txtValid.Text; // 是否默认 docGrantSetting.is_default = this.chkDefault.Checked ? "Y" : "N"; // 权限 if(this.chkPermission.SelectedIndex ==0 ) { docGrantSetting.permission_type_name = "控件浏览"; }else if(this.chkPermission.SelectedIndex ==1 ) { docGrantSetting.permission_type_name = "浏览"; }else if(this.chkPermission.SelectedIndex ==2 ) { docGrantSetting.permission_type_name = "下载"; } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 发放设置事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGrantSet_Click(object sender, EventArgs e) { GrantInfoBuild build = new GrantInfoBuild(docGrantSetting); if (build.ShowDialog() == DialogResult.OK) { docGrantSetting = build.docGrantSetting; // 设置成功! } }
/// <summary> /// 生成发放记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Name == "toolStripMenuItem1") { if (this.docGrantSetting == null || String.IsNullOrEmpty(this.docGrantSetting.permission_type_name)) { MessageBox.Show("请先设置发放信息!"); return; } if (String.IsNullOrEmpty(this.textEdit2.Text)) { MessageBox.Show("请先设置生效时间!"); return; } int count = 0; List<document> doclist = new List<document>(); // 获取选中的行 for (int i = 0; i < this.dgvDocument.RowCount; i++) { if (this.dgvDocument.GetRowCellValue(i, "gridControlCheck").Equals(true)) { count++; document doc = (document)this.dgvDocument.GetRow(i); doclist.Add(doc); } } if (count == 0) { MessageBox.Show("请选择需要发放的文档!"); return; } // 根据文档信息,增加发放记录 doc_grant_setting tenpSet = new doc_grant_setting(); tenpSet.grant_by_user = "******"; if (userNode.Tag.GetType() == typeof(user)) { tenpSet.grant_user = ((user)userNode.Tag).name; tenpSet.grant_type = "人员"; } else { tenpSet.grant_user = ((department)userNode.Tag).name; tenpSet.grant_type = "部门"; } tenpSet.permission_type_name = docGrantSetting.permission_type_name; tenpSet.valid_time = this.textEdit2.Text; tenpSet.in_valid_time = (DateTime.Parse(this.textEdit2.Text)).AddDays(Double.Parse(docGrantSetting.valid)).ToString("yyyy-MM-dd"); tenpSet.document_list = doclist; docGrantList.Add(tenpSet); this.dgcGrant.DataSource = docGrantList; this.dgcGrant.RefreshDataSource(); } }
/// <summary> /// 自定义构造函数 /// </summary> /// <param name="docGrantSetting"></param> public GrantInfoBuild(doc_grant_setting docGrantSetting) { InitializeComponent(); this.docGrantSetting = docGrantSetting; }
/// <summary> /// 查看文档发放设置 /// </summary> /// <param name="doc_grant"></param> /// <returns></returns> public List<doc_grant_setting> getGrantSetting(doc_grant_setting doc_grant) { List<doc_grant_setting> grantSetting = new List<doc_grant_setting>(); doc_grant_setting dg1 = new doc_grant_setting(); dg1.id = 1; dg1.grant_by_user = "******"; dg1.grant_type = "人员"; dg1.grant_user = "******"; dg1.in_valid_time = "2013-01-02"; dg1.valid_time = "2013-01-01"; dg1.permission_type_name = "控件浏览"; dg1.valid = "1"; grantSetting.Add(dg1); doc_grant_setting dg2 = new doc_grant_setting(); dg2.id = 1; dg2.grant_by_user = "******"; dg2.grant_type = "人员"; dg2.grant_user = "******"; dg2.in_valid_time = "2013-01-02"; dg2.valid_time = "2013-01-01"; dg2.permission_type_name = "控件浏览"; dg2.valid = "1"; grantSetting.Add(dg2); document D2 = new document(); D2.cn_name = "文档2"; D2.create_user_name = "李俊1"; D2.create_date = DateTime.Parse("2013-01-01"); D2.modify_count = "0"; D2.modify_date = DateTime.Parse("2013-01-01"); D2.modify_user_name = "李俊1"; D2.doc_page = "A4"; D2.dense_name = "保密"; D2.valid_time = "2013-01-01"; D2.in_valid_time = "2013-01-12"; D2.remark = "备注"; D2.status = "有效"; D2.format_name = "txt"; D2.version = "0002"; D2.abstract_content = "备注"; D2.en_name = "wendang2"; D2.number = "00002"; D2.key = "文档 设计文档 车轮"; D2.doc_template_id = 1; D2.doc_template_name = "需求设计文档"; D2.column1 = "12"; D2.column2 = "23"; D2.column3 = "34"; List<document> docList = new List<document>(); docList.Add(D2); dg1.document_list = docList; document D3 = new document(); D3.cn_name = "文档3"; D3.create_user_name = "李俊1"; D3.create_date = DateTime.Parse("2013-01-01"); D3.modify_count = "0"; D3.modify_date = DateTime.Parse("2013-01-01"); D3.modify_user_name = "李俊1"; D3.doc_page = "A4"; D3.dense_name = "保密"; D3.valid_time = "2013-01-01"; D3.in_valid_time = "2013-01-12"; D3.remark = "备注"; D3.status = "有效"; D3.format_name = "txt"; D3.version = "0002"; D3.abstract_content = "备注"; D3.en_name = "wendang2"; D3.number = "00002"; D3.key = "文档 设计文档 车轮"; D3.doc_template_id = 1; D3.doc_template_name = "需求设计文档"; D3.column1 = "12"; D3.column2 = "23"; D3.column3 = "34"; List<document> docList1 = new List<document>(); docList1.Add(D3); dg2.document_list = docList1; return grantSetting; }
/// <summary> /// 插入文档发放设置 /// </summary> /// <param name="doc_grant"></param> /// <returns></returns> public doc_grant_setting insertGrantSetting(doc_grant_setting doc_grant) { return doc_grant; }