protected void ViewButton_Click(object sender, EventArgs e)
        {
            int EmpID = (int)HttpContext.Current.Session["EmpID"];

            RequestDetailsGridView.Visible = false;
            RejectButton.Visible           = false;
            ApproveButton.Visible          = false;
            RemarksTextBox.Visible         = false;
            Label3.Visible = false;
            string status = StatusRadioButtonList.SelectedValue;

            ViewState["status"] = status;

            RequestGridView.DataSource = RequestBizLogic.ListRequests(status, EmpID);

            if (StatusRadioButtonList.SelectedValue == "Approved" || StatusRadioButtonList.SelectedValue == "Rejected")
            {
                RequestGridView.Columns[5].Visible = true;
                //GridView1.Columns[6].Visible = true;
            }
            else if (StatusRadioButtonList.SelectedValue == "Pending")
            {
                RequestGridView.Columns[5].Visible = false;
                //GridView1.Columns[6].Visible = false;
            }
            RequestGridView.DataBind();
            if (RequestGridView.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('No Requests');window.location ='ManageRequest.aspx';", true);
            }
        }
        protected void RequestGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            int    EmpID  = (int)HttpContext.Current.Session["EmpID"];
            string status = (string)ViewState["status"];

            RequestGridView.DataSource = RequestBizLogic.ListRequests(status, EmpID);

            RequestGridView.PageIndex = e.NewPageIndex;
            RequestGridView.DataBind();
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FormsAuthenticationEx.RedirectIfUserNotInRole("~/Default.aspx", "Client");

            // Only display requests for the currently logged-in client
            RequestDataSource.Where = "it.Contract.Client.Email = @email";
            RequestDataSource.WhereParameters.Clear();
            RequestDataSource.WhereParameters.Add("email", DbType.String, User.Identity.Name);

            if (!IsPostBack)
            {
                RequestGridView.DataBind();
            }
        }
Exemple #4
0
        protected void GetData()
        {
            RequestModel requestModel = new RequestModel();
            var          requestList  = requestModel.GetAllRequest();

            RequestGridView.DataSource = requestList;
            RequestGridView.DataBind();
            int pageSize = RequestGridView.AllowPaging == true ? RequestGridView.PageSize : 10;//默认行数是10行

            if (RequestGridView.Rows.Count == 0)
            {
                DataTable dt = new DataTable();
                // 当DataSource为空时绑定之,否则Gridview控件就不能显示
                DataRow dr;
                for (int i = 0; i < RequestGridView.Columns.Count - 1; i++)
                {
                    dt.Columns.Add(new DataColumn(((BoundField)RequestGridView.Columns[i]).DataField, typeof(string)));
                    dr    = dt.NewRow();
                    dr[i] = "&nbsp;";
                }
                dt.Columns.Add("Action");
                dr    = dt.NewRow();
                dr[6] = "&nbsp;";
                for (int j = 0; j < pageSize - RequestGridView.Rows.Count; j++)
                {
                    dr = dt.NewRow();
                    dt.Rows.Add(dr);
                }
                RequestGridView.DataSource = dt;
                RequestGridView.DataBind();
            }
            else
            {
                for (int i = 0; i < 10 - RequestGridView.Rows.Count; i++)
                {
                    int         rowIndex = RequestGridView.Rows.Count + i + 1;
                    GridViewRow row      = new GridViewRow(rowIndex, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
                    for (int j = 0; j < RequestGridView.Columns.Count - 3; j++)
                    {
                        TableCell cell = new TableCell();
                        cell.Text = "&nbsp;";
                        row.Controls.Add(cell);
                        row.Attributes.Add("BorderColor ", "#d2d2d2");
                    }

                    RequestGridView.Controls[0].Controls.AddAt(rowIndex, row);
                }
            }
        }
        protected void RequestGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            int    EmpID = (int)HttpContext.Current.Session["EmpID"];
            string value = (string)ViewState["value"];

            if (value == "Approved")
            {
                RequestGridView.DataSource = RequestBizLogic.ViewApprovedRequest(EmpID);//hardcord employeeId for testing
            }
            if (value == "Rejected")
            {
                RequestGridView.DataSource = RequestBizLogic.ViewRejectedRequest(EmpID);//hardcord employeeId for testing
            }
            RequestGridView.PageIndex = e.NewPageIndex;
            RequestGridView.DataBind();
        }
        protected void SelectButton_Click(object sender, EventArgs e)
        {
            int    EmpID = (int)HttpContext.Current.Session["EmpID"];
            string value = StatusRadioButtonList.SelectedValue;

            ViewState["value"] = value;
            if (value == "Pending")
            {
                PendingRequestGridView.DataSource = RequestBizLogic.ViewPendingRequest(EmpID);//hardcord employeeId for testing
                PendingRequestGridView.DataBind();
                RequestGridView.Columns[3].Visible = false;
                RequestGridView.Columns[4].Visible = false;
                PendingRequestGridView.Visible     = true;
                RequestGridView.Visible            = false;
                RequestDetailsGridView.Visible     = false;
                //DeleteButton.Visible = true;
            }
            if (value == "Approved")
            {
                RequestGridView.DataSource = RequestBizLogic.ViewApprovedRequest(EmpID);//hardcord employeeId for testing
                RequestGridView.DataBind();
                RequestGridView.Visible        = true;
                PendingRequestGridView.Visible = false;
                RequestDetailsGridView.Visible = false;
                //DeleteButton.Visible = false;
            }
            if (value == "Rejected")
            {
                RequestGridView.DataSource = RequestBizLogic.ViewRejectedRequest(EmpID);//hardcord employeeId for testing
                RequestGridView.DataBind();
                RequestGridView.Columns[3].Visible = false;
                RequestGridView.Visible            = true;
                PendingRequestGridView.Visible     = false;
                RequestDetailsGridView.Visible     = false;
                //DeleteButton.Visible = false;
            }
        }
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            DateTime firstDate = Convert.ToDateTime(txtFirst.Text);
            DateTime ff        = new DateTime(firstDate.Year, firstDate.Month, 1);
            DateTime fl        = ff.AddMonths(1).AddDays(-1);


            DateTime secondDate = Convert.ToDateTime(txtSecond.Text);
            DateTime sf         = new DateTime(secondDate.Year, secondDate.Month, 1);
            DateTime sl         = sf.AddMonths(1).AddDays(-1);


            DateTime thirdDate = Convert.ToDateTime(txtSecond.Text);
            DateTime tf        = new DateTime(thirdDate.Year, secondDate.Month, 1);
            DateTime tl        = tf.AddMonths(1).AddDays(-1);


            string type     = string.Empty;
            string category = string.Empty;
            if (rdPrice.Checked)
            {
                type = "Price";
            }
            else
            {
                type = "Quantity";
            }
            category = ddlCategory.SelectedItem.ToString();
            addColumn();
            List <ADTeam4EF.ReorderReport_View> firstRequestList  = rController.getFirstMonth(category, ff, fl);
            List <ADTeam4EF.ReorderReport_View> secondRequestList = rController.getSecondMonth(category, sf, sl);
            List <ADTeam4EF.ReorderReport_View> thirdRequestList  = rController.getThirdMonth(category, tf, tl);
            if (firstRequestList != null)
            {
                if (type == "Quantity")
                {
                    dt = ConvertListToDataTable(firstRequestList, "FirstMonth");
                }
                else
                {
                    dt = ConvertListToDataTablePrice(firstRequestList, "FirstMonth");
                }
            }
            if (secondRequestList != null)
            {
                if (type == "Quantity")
                {
                    dt = ConvertListToDataTable(secondRequestList, "SecondMonth");
                }
                else
                {
                    dt = ConvertListToDataTablePrice(secondRequestList, "SecondMonth");
                }
            }
            if (thirdRequestList != null)
            {
                if (type == "Quantity")
                {
                    dt = ConvertListToDataTable(thirdRequestList, "ThirdMonth");
                }
                else
                {
                    dt = ConvertListToDataTablePrice(thirdRequestList, "ThirdMonth");
                }
            }
            else if (firstRequestList == null && secondRequestList == null && thirdRequestList == null)
            {
                lblStatus.Visible           = true;
                RequestReportViewer.Visible = false;
            }
            ds.Tables[0].Merge(dt);
            //reportDoc.Load(Server.MapPath("~/Report/ReorderCrystalReport.rpt"));
            //reportDoc.SetDataSource(ds);
            //RequestReportViewer.ReportSource = reportDoc;
            //RequestReportViewer.Visible = true;
            lblStatus.Visible = false;
        }
        RequestGridView.DataSource = dt;
        RequestGridView.DataBind();
    }