Esempio n. 1
0
        protected override void CreateChildControls()
        {
            //base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
            this._gviewMyMessage = new SPGridView();

            HyperLinkField lf = new HyperLinkField();

            lf.HeaderText = "消息主题";
            //lf.DataTextField = "MessageTitle";
            //lf.DataNavigateUrlFields = new string[] { "MessageInfoID", "ReceiverID" };
            //lf.DataNavigateUrlFormatString = "MyMessage.aspx?curMessageInfoID={0}&curReceiverID={1}";

            //DataNavigateUrlFormatString不支持javascript
            //string relativeUrl = "MyMessage.aspx?curMessageInfoID={0}&curReceiverID={1}";
            //lf.DataNavigateUrlFormatString = "javascript:window.showModalDialog('" + relativeUrl + "','0','dialogWidth:300px;dialogHeight:450px');";
            //lf.DataNavigateUrlFormatString = "javascript:window.showModalDialog('MyMessage.aspx?curMessageInfoID={0}&curReceiverID={1}','0','dialogWidth:300px;dialogHeight:450px');";

            this._gviewMyMessage.Columns.Add(lf);

            BoundField bfCreateTime = new BoundField();

            bfCreateTime.HeaderText       = "日期";
            bfCreateTime.DataField        = "CreateTime";
            bfCreateTime.DataFormatString = "{0:yyyy-MM-dd}";
            this._gviewMyMessage.Columns.Add(bfCreateTime);

            BoundField bfMsgFromEmp = new BoundField();

            bfMsgFromEmp.HeaderText = "来自";
            bfMsgFromEmp.DataField  = "MsgFromEmp";
            this._gviewMyMessage.Columns.Add(bfMsgFromEmp);

            BoundField bfMessageStatus = new BoundField();

            bfMessageStatus.HeaderText = "状态";
            bfMessageStatus.DataField  = "MessageStatus";
            this._gviewMyMessage.Columns.Add(bfMessageStatus);

            this._gviewMyMessage.AutoGenerateColumns = false;
            this._gviewMyMessage.GridLines           = GridLines.None;
            this._gviewMyMessage.CssClass            = "ms-vh2 padded headingfont";
            this._gviewMyMessage.RowDataBound       += new GridViewRowEventHandler(_gviewMyMessage_RowDataBound);

            //this._gviewMyMessage.AllowPaging = true;
            //this._gviewMyMessage.PageSize = 1;
            //this._gviewMyMessage.PageIndexChanging +=new GridViewPageEventHandler(_gviewMyMessage_PageIndexChanging);
            //this._gviewMyMessage.PagerTemplate = new SPGridViewPagerTemplate("{0} - {1}", _gviewMyMessage);

            using (WebPartMMSProDBDataContext dc = new WebPartMMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                this._gviewMyMessage.DataSource = (from m in dc.MessageInfo
                                                   join r in dc.MessageReceiver on m.MessageInfoID equals r.MessageInfoID
                                                   where m.MessageStatus == "未读" && m.MessageType == "私有消息" && dc.EmpInfo.SingleOrDefault(e => e.EmpID == r.ReceiverID).Account == SPContext.Current.Web.CurrentUser.LoginName
                                                   orderby m.MessageInfoID descending
                                                   select new
                {
                    m.MessageInfoID,
                    r.ReceiverID,
                    m.MessageTitle,
                    m.CreateTime,
                    MsgFromEmp = dc.EmpInfo.SingleOrDefault(ee => ee.EmpID == m.Creater).EmpName,
                    m.MessageStatus
                }).Take(6);

                this._gviewMyMessage.DataBind();
            }
            Literal L1 = new Literal();

            L1.Text = "<table style='width:100%; text-align:right'><tr><td><a href='WorkPages/DocAndIndexManager/MoreMyMessage.aspx'>更多我的消息...</a></td></tr></table>";
            this.Controls.Add(this._gviewMyMessage);
            this.Controls.Add(L1);
            this.Title = "我的消息";
        }
Esempio n. 2
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);

            this._gviewTransferAndScrap = new SPGridView();
            this._gviewTransferAndScrap.RowDataBound += new GridViewRowEventHandler(_gviewTransferAndScrap_RowDataBound);

            //HyperLinkField hlf = new HyperLinkField();
            ////hlf.HeaderStyle.ForeColor = Color.Gray;
            //hlf.HeaderStyle.Font.Bold = true;
            //hlf.HeaderText = colNames[0].Split(':')[1];
            //hlf.DataTextField = colNames[0].Split(':')[0];
            //hlf.DataNavigateUrlFields = new string[] { "TaskStorageID", "StorageInID"};
            //hlf.DataNavigateUrlFormatString = SPContext.Current.Web.Url + "/WorkPages/StorageIn/QualityControlManage.aspx?TaskStorageID={0}&StorageInID={1}";
            TemplateField tfieldHyperLink = new TemplateField();

            tfieldHyperLink.ItemTemplate   = new HyperLinkTemplate("待办事项", DataControlRowType.DataRow, "TaskType", "TaskTitle");
            tfieldHyperLink.HeaderTemplate = new HyperLinkTemplate("待办事项", DataControlRowType.Header);
            this._gviewTransferAndScrap.Columns.Add(tfieldHyperLink);

            for (int i = 1; i < colNames.Length; i++)
            {
                BoundField bf = new BoundField();
                //bf.HeaderStyle.ForeColor = Color.Gray;
                bf.HeaderStyle.Font.Bold = true;
                bf.HeaderText            = colNames[i].Split(':')[1];
                bf.DataField             = colNames[i].Split(':')[0];
                if (i == 1)
                {
                    bf.DataFormatString = "{0:yyyy-MM-dd HH:mm dddd}";
                }
                //if (i == 3)
                //{
                //    TableItemStyle tis = new TableItemStyle();
                //    tis.ForeColor = System.Drawing.Color.Red;
                //    bf.DataFormatString = "";
                //}
                this._gviewTransferAndScrap.Columns.Add(bf);
            }

            this._gviewTransferAndScrap.AutoGenerateColumns = false;
            this._gviewTransferAndScrap.GridLines           = GridLines.None;
            this._gviewTransferAndScrap.CssClass            = "ms-vh2 padded headingfont";
            //string curLoginName = SPContext.Current.Web.CurrentUser.LoginName;
            using (WebPartMMSProDBDataContext dc = new WebPartMMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                this._gviewTransferAndScrap.DataSource = (from t in dc.StockTransferTask
                                                          join e1 in dc.EmpInfo on t.TaskTargetID equals e1.EmpID
                                                          join e2 in dc.EmpInfo on t.TaskCreaterID equals e2.EmpID
                                                          where e1.Account.ToLower() == SPContext.Current.Web.CurrentUser.LoginName.ToLower()
                                                          orderby t.StockTransferTaskID descending
                                                          select new
                {
                    t.StockTransferTaskID,
                    t.TaskTitle,
                    t.CreateTime,
                    e2.EmpName,
                    t.TaskState,
                    t.StockTransferID,
                    t.TaskType,
                    t.TaskInType
                }).Take(7);
                this._gviewTransferAndScrap.DataBind();
            }
            int colLastIndex = this._gviewTransferAndScrap.Columns.Count - 2;
            int rowLastIndex = this._gviewTransferAndScrap.Rows.Count - 1;

            for (int i = 0; i <= rowLastIndex; i++)
            {
                if (this._gviewTransferAndScrap.Rows[i].Cells[colLastIndex].Text == "已完成")
                {
                    this._gviewTransferAndScrap.Rows[i].Cells[colLastIndex].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    this._gviewTransferAndScrap.Rows[i].Cells[colLastIndex].ForeColor = System.Drawing.Color.Red;
                }
            }
            Literal L1 = new Literal();

            L1.Text = "<table style='width:100%; text-align:right'><tr><td><a href='workpages/DocAndIndexManager/MoreTransferAndScrap.aspx'>更多待办事项...</a></td></tr></table>";
            this.Controls.Add(this._gviewTransferAndScrap);
            this.Controls.Add(L1);
            this.Title = "移库&报废";
        }