Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["dsgcode"] != null)
            {
                var position = Convert.ToString(Session["dsgcode"]);
                if (position.Equals("l9", StringComparison.InvariantCultureIgnoreCase))
                {
                    lblmsg.Visible    = true;
                    dvExpense.Visible = false;
                }
            }
            var businessLayer = new AgressoDirectory.BusinessLogic.ExpenseManager();

            if (!Page.IsPostBack)
            {
                var dsExpenseType = businessLayer.GetExpenseType();
                ddlExpenseType.DataTextField  = dsExpenseType.Tables[0].Columns["ExpenseType"].ToString(); // text field name of table dispalyed in dropdown
                ddlExpenseType.DataValueField = dsExpenseType.Tables[0].Columns["ExpenseID"].ToString();   // to retrive specific  textfield name 
                ddlExpenseType.DataSource     = dsExpenseType.Tables[0];                                   //assigning datasource to the dropdownlist
                ddlExpenseType.DataBind();
                ddlExpenseType.Items.Insert(0, new ListItem("--Select--", "--Select--"));

                var dsProjects = businessLayer.GetProject();
                ddlProject.DataTextField  = dsProjects.Tables[0].Columns["ProjectType"].ToString(); // text field name of table dispalyed in dropdown
                ddlProject.DataValueField = dsProjects.Tables[0].Columns["ProjectId"].ToString();   // to retrive specific  textfield name 
                ddlProject.DataSource     = dsProjects.Tables[0];                                   //assigning datasource to the dropdownlist
                ddlProject.DataBind();
                ddlProject.Items.Insert(0, new ListItem("--Select--", "--Select--"));


                var dsApprover = businessLayer.GetApprover();
                ddlApprover.DataTextField  = dsApprover.Tables[0].Columns["name"].ToString();   // text field name of table dispalyed in dropdown
                ddlApprover.DataValueField = dsApprover.Tables[0].Columns["UserID"].ToString(); // to retrive specific  textfield name 
                ddlApprover.DataSource     = dsApprover.Tables[0].DefaultView;                  //assigning datasource to the dropdownlist
                                                                                                //ddlApprover.SelectedIndex = -1;
                ddlApprover.DataBind();


                ddlApprover.Items.Insert(0, new ListItem("--Select Approver--", "--Select Approver--"));
            }
        }
Ejemplo n.º 2
0
        protected void ExpenseDetails_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                // BIND THE "DROPDOWNLIST" WITH THE DATASET FILLED WITH "Project"
                DropDownList Project = new DropDownList();
                Project = (DropDownList)e.Row.FindControl("Project");

                if (Project != null)
                {
                    var businessLayer = new AgressoDirectory.BusinessLogic.ExpenseManager();
                    var dsProjects    = businessLayer.GetProject();
                    Project.DataTextField  = dsProjects.Tables[0].Columns["ProjectType"].ToString(); // text field name of table dispalyed in dropdown
                    Project.DataValueField = dsProjects.Tables[0].Columns["ProjectId"].ToString();   // to retrive specific  textfield name 
                    Project.DataSource     = dsProjects.Tables[0];                                   //assigning datasource to the dropdownlist
                    Project.DataBind();

                    // ASSIGN THE SELECTED ROW VALUE ("ProjectCode") TO THE DROPDOWNLIST SELECTED VALUE.
                    Project.SelectedIndex = Project.Items.IndexOf(Project.Items.FindByText(DataBinder.Eval(e.Row.DataItem, "ProjectType").ToString()));
                }

                DropDownList Approver = new DropDownList();
                Approver = (DropDownList)e.Row.FindControl("txtEditApproverId");

                if (Approver != null)
                {
                    var businessLayer = new AgressoDirectory.BusinessLogic.ExpenseManager();
                    var dsApprover    = businessLayer.GetApprover();
                    Approver.DataTextField  = dsApprover.Tables[0].Columns["name"].ToString();   // text field name of table dispalyed in dropdown
                    Approver.DataValueField = dsApprover.Tables[0].Columns["UserID"].ToString(); // to retrive specific  textfield name 
                    Approver.DataSource     = dsApprover.Tables[0];                              //assigning datasource to the dropdownlist
                    Approver.DataBind();

                    // ASSIGN THE SELECTED ROW VALUE ("QUALIFICATION CODE") TO THE DROPDOWNLIST SELECTED VALUE.
                    Approver.SelectedIndex = Project.Items.IndexOf(Approver.Items.FindByText(DataBinder.Eval(e.Row.DataItem, "name").ToString()));
                }

                DropDownList ExpenseType = new DropDownList();
                ExpenseType = (DropDownList)e.Row.FindControl("txtEditExpenseTypeId");

                if (Approver != null)
                {
                    var businessLayer = new AgressoDirectory.BusinessLogic.ExpenseManager();
                    var dsExpenseType = businessLayer.GetExpenseType();
                    ExpenseType.DataTextField  = dsExpenseType.Tables[0].Columns["ExpenseType"].ToString(); // text field name of table dispalyed in dropdown
                    ExpenseType.DataValueField = dsExpenseType.Tables[0].Columns["ExpenseID"].ToString();   // to retrive specific  textfield name 
                    ExpenseType.DataSource     = dsExpenseType.Tables[0];                                   //assigning datasource to the dropdownlist
                    ExpenseType.DataBind();

                    // ASSIGN THE SELECTED ROW VALUE ("QUALIFICATION CODE") TO THE DROPDOWNLIST SELECTED VALUE.
                    ExpenseType.SelectedIndex = Project.Items.IndexOf(ExpenseType.Items.FindByText(DataBinder.Eval(e.Row.DataItem, "ExpenseType").ToString()));
                }


                DropDownList StatusType = new DropDownList();
                StatusType = (DropDownList)e.Row.FindControl("txtEdiStatusId");

                if (Approver != null)
                {
                    var businessLayer = new AgressoDirectory.BusinessLogic.ExpenseManager();
                    var dsStatusType  = businessLayer.GetStatus();
                    StatusType.DataTextField  = dsStatusType.Tables[0].Columns["Status"].ToString();   // text field name of table dispalyed in dropdown
                    StatusType.DataValueField = dsStatusType.Tables[0].Columns["StatusID"].ToString(); // to retrive specific  textfield name 
                    StatusType.DataSource     = dsStatusType.Tables[0];                                //assigning datasource to the dropdownlist
                    StatusType.DataBind();

                    // ASSIGN THE SELECTED ROW VALUE ("QUALIFICATION CODE") TO THE DROPDOWNLIST SELECTED VALUE.
                    StatusType.SelectedIndex = Project.Items.IndexOf(StatusType.Items.FindByText(DataBinder.Eval(e.Row.DataItem, "Status").ToString()));
                }
            }
        }