123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- using LYFZ.BLL;
- 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;
- namespace LYFZ.Software.MainBusiness.OAShopManagement
- {
- public class frmBulletinBoard : LYFZ.Software.UI.OAShopManagement.frmBulletinBoard
- {
- LYFZ.BLL.BLL_ErpShopBulletin sbbll = new BLL_ErpShopBulletin();
- LYFZ.BLL.BLL_ErpShopDesignatedAnnounced sdbll = new BLL_ErpShopDesignatedAnnounced();
- public frmBulletinBoard()
- {
- this.tabControlBulletinBoard.SelectedIndexChanged += tabControlBulletinBoard_SelectedIndexChanged;
- this.btndel.Click += btndel_Click;
- this.btnClose.Click += btnClose_Click;
- this.btnAdd.Click += btnAdd_Click;
- this.dgvBulletinBoard.CellDoubleClick += dgvBulletinBoard_CellDoubleClick;
- this.ucNotice.EventPaging += ucNotice_EventPaging;
- this.ucNotice.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
- this.Shown += frmBulletinBoard_Shown;
- this.btnAdd.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.BulletinBoardCompetence, CustomAttributes.OperatingAuthority.Announcement);
- this.btndel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.BulletinBoardCompetence, CustomAttributes.OperatingAuthority.Delete);
- }
- DataTable dtUser = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable;
- /// <summary>
- /// 当前用户ID
- /// </summary>
- string EmployeeID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmBulletinBoard_Shown(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvBulletinBoard_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (this.dgvBulletinBoard.Rows.Count > 0)
- {
- if (this.dgvBulletinBoard.CurrentRow != null)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- frmReleaseBulletinBoard frm = new frmReleaseBulletinBoard();
- frm.StrGGNumber = this.dgvBulletinBoard.CurrentRow.Cells["公告ID"].Value.ToString().Trim();
- frm.ShowDialog();
- if (frm.IsSaveed)
- { this.PublicFunctionRows(); }
- }
- }
- }
- }
- /// <summary>
- /// 发布公告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAdd_Click(object sender, EventArgs e)
- {
- frmReleaseBulletinBoard frm = new frmReleaseBulletinBoard();
- frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- frm.StrType = this.tabControlType();
- frm.ShowDialog();
- if (frm.IsSaveed)
- {
- if (frm.CurrentBulletinModel != null)
- {
- System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(BulletinBoardPushMessage),new object[]{ frm.CurrentBulletinModel,frm.CurrentPersonModel});
- }
- this.PublicFunctionRows();
- }
- }
- /// <summary>
- /// 发布公告时推送消息
- /// </summary>
- void BulletinBoardPushMessage(object b)
- {
- try
- {
- if (b != null)
- {
- object[] barry = (object[])b;
- LYFZ.Model.Model_ErpShopBulletin buuletinModel = (Model.Model_ErpShopBulletin)barry[0];
- LYFZ.Model.Model_ErpShopDesignatedAnnounced personModel = (LYFZ.Model.Model_ErpShopDesignatedAnnounced)barry[1];
- sbbll.BulletinBoardPushMessage(buuletinModel, personModel);
- }
- }
- catch { }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 删除公告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btndel_Click(object sender, EventArgs e)
- {
- if (this.dgvBulletinBoard.Rows.Count > 0)
- {
- if (this.dgvBulletinBoard.SelectedRows != null)
- {
- if (this.dgvBulletinBoard.CurrentCell.RowIndex >= 0 && this.dgvBulletinBoard.CurrentRow.Index >= 0)
- {
- if (MessageBoxCustom.Show("是否删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- string StrGGNumber = dgvBulletinBoard.Rows[dgvBulletinBoard.CurrentRow.Index].Cells["公告ID"].Value.ToString();
- string StrPath = dgvBulletinBoard.Rows[dgvBulletinBoard.CurrentRow.Index].Cells["文件路径"].Value.ToString();
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- clist.Add(sbbll.GetDeleteCommandInfo(whereStr: "Bulletin_TheID = '" + StrGGNumber + "'"));
- clist.Add(sdbll.GetDeleteCommandInfo(whereStr: "Announced_announcement = '" + StrGGNumber + "'"));
- if (StrPath != "")
- {
- string[] StrArray = StrPath.Split('|');
- LYFZ.Software.MainBusiness.TCPFileTransfer tcpFile = new MainBusiness.TCPFileTransfer();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在连接服务器...");
- try
- {
- for (int i = 0; i < StrArray.Length; i++)
- {
- if (!string.IsNullOrEmpty(StrArray[i].Trim()))
- { string ret = tcpFile.DeleteFile(StrArray[i].Trim(), backgroundWorker); }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
- });
- }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- { this.PublicFunctionRows(); }
- else
- { MessageBoxCustom.Show("删除失败"); }
- }
- }
- }
- else
- { MessageBoxCustom.Show("请选择想要删除的公告"); }
- }
- }
- /// <summary>
- /// 选项卡选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void tabControlBulletinBoard_SelectedIndexChanged(object sender, EventArgs e)
- {
- ucNotice.Bind();
- ShowDgvBulletinBoard(this.tabControlBulletinBoard.TabPages[this.tabControlBulletinBoard.SelectedIndex]);
- }
- void ShowDgvBulletinBoard(TabPage pge)
- {
- pge.Margin = new System.Windows.Forms.Padding(0);
- pge.Padding = new Padding(0);
- this.dgvBulletinBoard.Margin = new System.Windows.Forms.Padding(0);
- this.dgvBulletinBoard.Dock = DockStyle.Fill;
- this.dgvBulletinBoard.Location = new Point(0, 0);
- pge.Controls.Clear();
- pge.Controls.Add(this.dgvBulletinBoard);
- }
- private delegate void UpdateControl();
- /// <summary>
- /// 公共刷新方法
- /// </summary>
- public void PublicFunctionRows()
- {
- ucNotice.Bind();
- }
- //分页
- public int ucNotice_EventPaging(UCPager.EventPagingArg e)
- {
- if (dgvBulletinBoard.Rows.Count > 0)
- { dgvBulletinBoard.Rows.Clear(); }
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- pageData.TableName = "Vw_ErpShopBulletin";
- pageData.PageIndex = this.ucNotice.PageCurrent;
- pageData.PageSize = this.ucNotice.PageSize;
- pageData.QueryCondition = " (可看指定人ID like '%" + EmployeeID + "%' or 可看指定人ID is null or 可看指定人ID='1') and 公告类型 like '%" + tabControlType() + "%'";
- pageData.QueryFieldName = "发布人姓名,公告类型,标题,内容,发布时间,发布人ID,文件路径,可看指定人ID,公告ID,可看公告ID,已读人员";//可看指定人姓名
- pageData.OrderStr = "ID desc";
- pageData.OrderType = 1;
- DataTable dt = pageData.QueryDataTable().Tables[0];
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- #region
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
-
- //标题
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["已读人员"].ToString().IndexOf(EmployeeID) == -1 ? "【新】 " + dt.Rows[t]["标题"].ToString().Trim() : dt.Rows[t]["标题"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //内容
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["内容"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //公告类型
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["公告类型"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //发布人姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["发布人姓名"].ToString().Trim();
- dgvr.Cells.Add(cell);
-
- //发布时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[t]["发布时间"], "yyyy-MM-dd HH:mm");
- dgvr.Cells.Add(cell);
- //可看指定人姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["可看指定人ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //发布人
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["发布人ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //文件路径
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["文件路径"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //可看指定人
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["可看指定人ID"].ToString();
- dgvr.Cells.Add(cell);
- //公告
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["公告ID"].ToString();
- dgvr.Cells.Add(cell);
- //是否已看
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["已读人员"].ToString().IndexOf(EmployeeID) == -1 ? "on" : "ok";
- dgvr.Cells.Add(cell);
- //已看人员
- cell = new DataGridViewTextBoxCell();
- string[] strArray = dt.Rows[t]["已读人员"].ToString().Trim().Split(',');
- string StrSeenPerson = "";
- string StrSeenPersonNumber = "";
- for (int i = 0; i < strArray.Length; i++)
- {
- if (strArray[i].Trim() != LYFZ.BLL.BLL_ErpUser.Admin_20141125111443713)
- {
- StrSeenPersonNumber += strArray[i].Trim() + ",";
- DataRow dtRow = dtUser.Rows.Find(strArray[i].Trim());
- if (dtRow != null)
- { StrSeenPerson += dtRow["User_Name"].ToString() + ","; }
- }
- }
- cell.Value = StrSeenPerson;// Nsername(dt.Rows[t]["已读人员"].ToString().Trim());
- dgvr.Cells.Add(cell);
- this.dgvBulletinBoard.Rows.Add(dgvr);
- dgvBulletinBoard.ClearSelection();
- }
- #endregion
- }));
- });
- try
- {
- if (dt != null)
- { this.ucNotice.TbDataSource = dt; }
- }
- catch
- { }
- return pageData.TotalCount;
- }
- /// <summary>
- /// 返回当前选项卡的值
- /// </summary>
- /// <returns></returns>
- string tabControlType()
- {
- string StrBulletinType = "";
- switch (tabControlBulletinBoard.SelectedIndex)
- {
- case 0: StrBulletinType = ""; break;
- case 1: StrBulletinType = enumBulletinType.日常公告.ToString(); break;
- case 2: StrBulletinType = enumBulletinType.规章制度.ToString(); break;
- case 3: StrBulletinType = enumBulletinType.荣誉表彰.ToString(); break;
- case 4: StrBulletinType = enumBulletinType.惩罚警示.ToString(); break;
- case 5: StrBulletinType = enumBulletinType.员工手册.ToString(); break;
- case 6: StrBulletinType = enumBulletinType.学习资料.ToString(); break;
- }
- return StrBulletinType;
- }
- enum enumBulletinType
- {
- 最新公告,
- 日常公告,
- 规章制度,
- 荣誉表彰,
- 惩罚警示,
- 员工手册,
- 学习资料
- }
- }
- }
|