private void GetParent()
        {
            string    sql = "SELECT DISTINCT WS_ID,WS_NAME FROM TBWS_WAREHOUSE WHERE WS_FATHERID<>'ROOT' ORDER BY WS_ID";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);

            DropDownListParent.DataSource     = dt;
            DropDownListParent.DataTextField  = "WS_NAME";
            DropDownListParent.DataValueField = "WS_ID";
            DropDownListParent.DataBind();
        }
        private void GetParent()
        {
            string    sql = "SELECT DISTINCT WS_NAME,WS_ID FROM TBWS_WAREHOUSE WHERE WS_FATHERID='ROOT' ORDER BY WS_ID";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);
            DataRow   row = dt.NewRow();

            row["WS_NAME"] = "ROOT";
            row["WS_ID"]   = "ROOT";
            dt.Rows.InsertAt(row, 0);
            DropDownListParent.DataTextField  = "WS_NAME";
            DropDownListParent.DataValueField = "WS_ID";
            DropDownListParent.DataSource     = dt;
            DropDownListParent.DataBind();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] != null)
            {
                userID = Int32.Parse(Session["UserID"].ToString());

                eRegisterData.DAL DAL  = new eRegisterData.DAL();
                SqlConnection     conn = DAL.getSubject();
                SqlCommand        comm = new SqlCommand();

                try
                {
                    conn.Open();
                    comm.Connection  = conn;
                    comm.CommandText = @" SELECT ActorID
                                      FROM Actors
                                      WHERE UserID='" + userID + "'";

                    studentID = Int32.Parse(comm.ExecuteScalar().ToString());
                    conn.Close();
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                }

                if (!IsPostBack)
                {
                    System.Data.DataTable teacherName = new System.Data.DataTable();
                    eRegisterData.DAL     oDal        = new eRegisterData.DAL();
                    teacherName = oDal.GetActors(2);
                    DropDownListTeacher.DataSource     = teacherName.DefaultView;
                    DropDownListTeacher.DataTextField  = teacherName.Columns["Name"].ColumnName.ToString();
                    DropDownListTeacher.DataValueField = teacherName.Columns["ActorID"].ColumnName.ToString();
                    DropDownListTeacher.DataBind();
                    DropDownListTeacher.Items.Add(new ListItem("Моля изберете", "-1"));
                    DropDownListTeacher.SelectedIndex = DropDownListTeacher.Items.Count - 1;

                    System.Data.DataTable parentName = new System.Data.DataTable();
                    eRegisterData.DAL     oDal1      = new eRegisterData.DAL();
                    parentName = oDal1.GetActors(3);
                    DropDownListParent.DataSource     = parentName.DefaultView;
                    DropDownListParent.DataTextField  = parentName.Columns["Name"].ColumnName.ToString();
                    DropDownListParent.DataValueField = parentName.Columns["ActorID"].ColumnName.ToString();
                    DropDownListParent.DataBind();
                    DropDownListParent.Items.Add(new ListItem("Моля изберете", "-1"));
                    DropDownListParent.SelectedIndex = DropDownListParent.Items.Count - 1;

                    System.Data.DataTable studentName = new System.Data.DataTable();
                    eRegisterData.DAL     oDal2       = new eRegisterData.DAL();
                    studentName = oDal2.GetActors(4);
                    DropDownListStudent.DataSource     = studentName.DefaultView;
                    DropDownListStudent.DataTextField  = studentName.Columns["Name"].ColumnName.ToString();
                    DropDownListStudent.DataValueField = studentName.Columns["ActorID"].ColumnName.ToString();
                    DropDownListStudent.DataBind();
                    DropDownListStudent.Items.Add(new ListItem("Моля изберете", "-1"));
                    DropDownListStudent.SelectedIndex = DropDownListStudent.Items.Count - 1;

                    System.Data.DataTable messageTypeInfo = new System.Data.DataTable();
                    eRegisterData.DAL     oDal3           = new eRegisterData.DAL();
                    messageTypeInfo = oDal3.getMessageType();
                    DropDownListMessageType.DataSource     = messageTypeInfo.DefaultView;
                    DropDownListMessageType.DataTextField  = messageTypeInfo.Columns["Type"].ColumnName.ToString();
                    DropDownListMessageType.DataValueField = messageTypeInfo.Columns["MessageTypeID"].ColumnName.ToString();
                    DropDownListMessageType.DataBind();
                    DropDownListMessageType.Items.Add(new ListItem("Моля изберете", "-1"));
                    DropDownListMessageType.SelectedIndex = DropDownListMessageType.Items.Count - 1;
                }
            }
            else
            {
                Response.Redirect("~/eRegister.aspx");
            }
        }