//Method used to populate all dropdown lists in the modals
    protected void DropDownPop()
    {
        try
        {
            SqlConnection con = new SqlConnection(ConnectionString.GetConnectionString("invDBConStr"));
            con.Open();

            SqlCommand     com = new SqlCommand("select SupplierName, SupplierID from Suppliers", con); // table name
            SqlDataAdapter da  = new SqlDataAdapter(com);
            DataSet        ds  = new DataSet();
            da.Fill(ds);                                                                           // fill dataset
            DropDownListsupplier.DataTextField  = ds.Tables[0].Columns["SupplierName"].ToString(); // text field name of table dispalyed in dropdown
            DropDownListsupplier.DataValueField = ds.Tables[0].Columns["SupplierID"].ToString();   // to retrive specific  textfield name
            DropDownListsupplier.DataSource     = ds.Tables[0];                                    //assigning datasource to the dropdownlist
            DropDownListsupplier.DataBind();                                                       //binding dropdownlist
            DropDownListsupplier.Items.Add(new ListItem("--New Supplier--", "--New Supplier--"));


            com = new SqlCommand("select * from Departments", con); // table name
            da  = new SqlDataAdapter(com);
            ds  = new DataSet();
            da.Fill(ds);                                                                        // fill dataset
            DropDownListDep.DataTextField  = ds.Tables[0].Columns["DepartmentName"].ToString(); // text field name of table dispalyed in dropdown
            DropDownListDep.DataValueField = ds.Tables[0].Columns["DepartmentID"].ToString();   // to retrive specific  textfield name
            DropDownListDep.DataSource     = ds.Tables[0];                                      //assigning datasource to the dropdownlist
            DropDownListDep.DataBind();                                                         //binding dropdownlist
            con.Close();
        }
        catch (SqlException exception)
        {
        }
    }
        //部门
        protected void GetDep()
        {
            string    sql = "SELECT DISTINCT DEP_CODE,DEP_NAME FROM TBDS_DEPINFO";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);

            DropDownListDep.DataTextField  = "DEP_NAME";
            DropDownListDep.DataValueField = "DEP_CODE";
            DropDownListDep.DataSource     = dt;
            DropDownListDep.DataBind();
        }
Example #3
0
        //领料部门

        protected void GetDep()
        {
            string    sql = "SELECT DISTINCT DEP_CODE,DEP_NAME FROM TBDS_DEPINFO WHERE DEP_CY='1' and DEP_SFJY='0'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);

            DropDownListDep.DataValueField = "DEP_CODE";
            DropDownListDep.DataTextField  = "DEP_NAME";
            DropDownListDep.DataSource     = dt;
            DropDownListDep.DataBind();
            ListItem item = new ListItem("--请选择--", "0");

            DropDownListDep.Items.Insert(0, item);
        }
        //绑定原始单据数据
        private void BindOriForm()
        {
            string Code = Request.QueryString["ID"].ToString();

            string    sql = "SELECT OP_TSAID,OP_DEP,OP_NOTE FROM TBWS_OUT WHERE OP_CODE='" + Code + "'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);

            if (dt.Rows.Count > 0)
            {
                TextBoxSCZH.Text = dt.Rows[0]["OP_TSAID"].ToString();
                DropDownListDep.ClearSelection();

                try { DropDownListDep.Items.FindByValue(dt.Rows[0]["OP_DEP"].ToString()).Selected = true; }
                catch { }

                try { DropDownListBZ.Items.FindByValue(dt.Rows[0]["OP_NOTE"].ToString()).Selected = true; }
                catch { }
            }
        }