private void In_bound(object sender, RoutedEventArgs e)
        {
            ///写入数据库
            try
            {
                List <Model.Inbound> lists = (List <Model.Inbound>)datagridinbound.ItemsSource;


                int i = datagridinbound.SelectedIndex;

                DataRowView   dataRowView = null;
                Model.Inbound list        = lists[i];

                WPF_SetToBox wPF_SetToBox = new WPF_SetToBox(dataRowView, "input_excel", list);
                string       sql          = "select Box_ID from Box where Box_Capacity < 100 and Box_Status='可存放'";
                DataSet      ds           = MySQLHelper.GetDataSet(MySQLHelper.GetConn(), CommandType.Text, sql, null);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    wPF_SetToBox.combobox.Items.Add(row["Box_ID"].ToString());;
                }
                wPF_SetToBox.combobox.Items.Add("托板");;
                wPF_SetToBox.ShowDialog();
                if (wPF_SetToBox.DialogResult == true)//第3步,然后对DialogResult进行判断
                {
                    lists.RemoveAt(i);
                    datagridinbound.ItemsSource = null;
                    datagridinbound.ItemsSource = lists;
                }
            }
            catch (InvalidCastException a)
            {
                MessageBox.Show("只有导入的入库excel才能进行入库操作");
            }
        }
Example #2
0
 public WPF_SetToBox(DataRowView view, string operation, YF_WMS.Model.Inbound list)
 {
     InitializeComponent();
     _view      = view;
     _operation = operation;
     _list      = list;
     if (_list != null)
     {
         material_pqty.Text = _list.Material_PQty.ToString();
         material_qty.Text  = _list.Material_PQty.ToString();
     }
 }
        private void Input_Excel(object sender, RoutedEventArgs e)
        {
            ///弹出文件选择对话框,选取Excel文件
            ///把Excel文件内容读至数组
            ///把数组添加到表Inbound

            //DataTable dt = InputExcel.GetTable();
            DataTable dt = InputToExcel.ExcelToDataTable(true);

            try
            {
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        List <Model.Inbound> lists = new List <Model.Inbound>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ///导入的数据模板
                            Model.Inbound u = new Model.Inbound();
                            // if (dt.Rows[i][0].GetType() == typeof(DBNull)) { u.Inbound_ID = ""; } else { u.Inbound_ID = dt.Rows[i][0].ToString(); }
                            u.Inbound_ID         = dt.Rows[i][0].ToString();
                            u.Inbound_Time       = dt.Rows[i][1].ToString();
                            u.Supplier_Name      = dt.Rows[i][2].ToString();
                            u.Box_ID             = dt.Rows[i][4].ToString();
                            u.Purchase_ID        = dt.Rows[i][3].ToString();
                            u.Material_ID        = dt.Rows[i][5].ToString();
                            u.Material_Spec      = dt.Rows[i][6].ToString();
                            u.Material_PQty      = Convert.ToInt32(dt.Rows[i][7]);
                            u.Material_SerialNum = dt.Rows[i][8].ToString();
                            lists.Add(u);
                        }
                        datagridinbound.ItemsSource = lists;
                    }
                }
                else
                {
                    MessageBox.Show("excel表格式错误,请重新导入");
                }
            }
            catch (ArgumentException a)
            {
                throw a;
            }
        }