Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DepartmentController      departmentController      = new DepartmentController();
            CollectionPointController collectionPointController = new CollectionPointController();

            int department_id;

            if (int.TryParse(Request.QueryString["id"], out department_id))
            {
                department_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                if (department_id < 1)
                {
                    Response.Redirect("~/StoreClerk/DepartmentList.aspx");
                }

                Department department = departmentController.actionGetDepartmentByID(department_id);
                if (!Page.IsPostBack)
                {
                    ui_id_hiddenfield.Value            = department.id.ToString();
                    ui_deptcode_textbox.Text           = department.code;
                    ui_deptname_textbox.Text           = department.department_name;
                    ui_contactname_textbox.Text        = department.contact_name;
                    ui_phone_textbox.Text              = department.phone;
                    ui_representativename_textbox.Text = department.representative_name;

                    ui_depthead_dropdown.DataSource     = departmentController.actionGetUsersOfADepartment(department_id);
                    ui_depthead_dropdown.DataTextField  = "username";
                    ui_depthead_dropdown.DataValueField = "id";
                    ui_depthead_dropdown.DataBind();
                    ui_depthead_dropdown.SelectedValue = department.department_head.ToString();

                    ui_collectionpoint_dropdown.DataSource     = collectionPointController.actionGetCollectionPoints();
                    ui_collectionpoint_dropdown.DataTextField  = "name";
                    ui_collectionpoint_dropdown.DataValueField = "id";
                    ui_collectionpoint_dropdown.DataBind();
                    ui_collectionpoint_dropdown.SelectedValue = department.collection_point.ToString();
                }
            }
            else
            {
                String tmp_depthead = ui_depthead_dropdown.SelectedValue;
                String tmp_colpoint = ui_collectionpoint_dropdown.SelectedValue;
                ui_depthead_dropdown.DataSource     = departmentController.actionGetUsersOfADepartment(department_id);
                ui_depthead_dropdown.DataTextField  = "username";
                ui_depthead_dropdown.DataValueField = "id";
                ui_depthead_dropdown.DataBind();

                ui_collectionpoint_dropdown.DataSource     = collectionPointController.actionGetCollectionPoints();
                ui_collectionpoint_dropdown.DataTextField  = "name";
                ui_collectionpoint_dropdown.DataValueField = "id";
                ui_collectionpoint_dropdown.DataBind();

                ui_depthead_dropdown.SelectedValue        = tmp_depthead;
                ui_collectionpoint_dropdown.SelectedValue = tmp_colpoint;
            }
        }