private void User_Input(object sender, RoutedEventArgs e)
        {
            ///导入excel到datagrid
            ///
            DataTable dt = InputExcel.GetTable();

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    List <Model.User> lists = new List <Model.User>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Model.User u = new Model.User();
                        u.Username = dt.Rows[i][0].ToString();
                        u.Password = dt.Rows[i][1].ToString();
                        lists.Add(u);
                    }
                    datagriduser.ItemsSource = lists;
                }
            }
            else
            {
                MessageBox.Show("excel表格式错误,请重新导入");
            }
        }
        private void InputToExcel(object sender, RoutedEventArgs e)
        {
            ///将excel数据导入到datagrid
            ///
            DataTable dt = InputExcel.GetTable();

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    List <Model.Material> lists = new List <Model.Material>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Model.Material u = new Model.Material();
                        u.Material_ID   = dt.Rows[i][0].ToString();
                        u.Material_Spec = dt.Rows[i][1].ToString();
                        u.Material_Qty  = Convert.ToInt32(dt.Rows[i][2]);
                        u.Box_ID        = Convert.ToInt32(dt.Rows[i][3]);
                        lists.Add(u);
                    }
                    datagridmaterial.ItemsSource = lists;
                }
            }
            else
            {
                MessageBox.Show("excel表格式错误,请重新导入");
            }
        }
Exemple #3
0
        private void Shelf_Input(object sender, RoutedEventArgs e)
        {
            DataTable dt = InputExcel.GetTable();

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    List <Model.Shelf> lists = new List <Model.Shelf>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Model.Shelf u = new Model.Shelf();
                        u.Shelf_ID     = dt.Rows[i][1].ToString();
                        u.Shelf_Area   = Convert.ToInt32(dt.Rows[i][2]);
                        u.Shelf_Row    = Convert.ToInt32(dt.Rows[i][2]);
                        u.Shelf_Column = Convert.ToInt32(dt.Rows[i][2]);
                        u.Shelf_Status = dt.Rows[i][1].ToString();
                        lists.Add(u);
                    }
                    datagridshelf.ItemsSource = lists;
                }
            }
            else
            {
                MessageBox.Show("excel表格式错误,请重新导入");
            }
        }
Exemple #4
0
        private void Box_Input(object sender, RoutedEventArgs e)
        {
            DataTable dt = InputExcel.GetTable();

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    List <Model.Box> lists = new List <Model.Box>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Model.Box u = new Model.Box();
                        u.Box_ID       = Convert.ToInt32(dt.Rows[i][0]);
                        u.Box_Color    = dt.Rows[i][1].ToString();
                        u.Box_Capacity = Convert.ToInt32(dt.Rows[i][2]);
                        u.Box_Status   = dt.Rows[i][3].ToString();
                        u.Box_Desc     = dt.Rows[i][4].ToString();
                        u.Shelf_ID     = dt.Rows[i][5].ToString();
                        lists.Add(u);
                    }
                    datagridbox.ItemsSource = lists;
                }
            }
            else
            {
                MessageBox.Show("excel表格式错误,请重新导入");
            }
        }