private void MenuItem_Click(object sender, RoutedEventArgs e)
 {
     #region  除方法
     if (this.DataGrid.SelectedCells.Count != 0)
     {
         ProductManagement_DevlieryDetailModel m = DataGrid.SelectedCells[0].Item as ProductManagement_DevlieryDetailModel;
         CellId = m.Id;
         if (!m.ProductID.Equals(Guid.Empty))
         {
             if (MessageBox.Show("是否删除此行数据?", "确认信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 bool flag = new DeliveryProcessOutConsole().DeleteDetail(m);
                 if (!flag)
                 {
                     MessageBox.Show("删除不成功!未找到对应数据!");
                 }
             }
             else
             {
                 return;
             }
         }
         m.Number    = "";
         m.Name      = "";
         m.QuantityA = 0;
         m.QuantityB = 0;
         m.QuantityC = 0;
     }
     #endregion
 }
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            ProductManagement_DevlieryDetailModel model = this.DataGrid.SelectedCells[0].Item as ProductManagement_DevlieryDetailModel;
            string newValue = (e.EditingElement as TextBox).Text.Trim();
            string Header   = e.Column.Header.ToString();

            if (Header == "编号")
            {
                if (ComboBox_Processors.SelectedIndex == 0)
                {
                    MessageBox.Show("请选择抛光户!");
                    return;
                }
                if (string.IsNullOrEmpty(newValue))
                {
                    return;
                }
                int d = 0;
                ProductManagement_DevlieryDetailModel m = new ProductManagement_DevlieryDetailModel();
                new DeliveryProcessOutConsole().ReadProductInfo((Guid)ComboBox_Processors.SelectedValue, newValue, out m, out d);
                if (string.IsNullOrEmpty(m.Name))
                {
                    MessageBox.Show("找不到编号对应的品名");
                    data[data.IndexOf(model)].Number = "";
                    DataGrid.CurrentCell             = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[0]);
                    return;
                }
                DataGrid.CurrentCell = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[2]);
                data[data.IndexOf(model)].ProductID = m.ProductID;
                data[data.IndexOf(model)].Name      = m.Name;
                data[data.IndexOf(model)].QuantityB = d;
            }
            else if (Header.Equals("领货数量"))
            {
                int temp = 0;
                int.TryParse(newValue, out temp);
                data[data.IndexOf(model)].QuantityC = temp + data[data.IndexOf(model)].QuantityB;
            }
        }
        internal bool ReadProductInfo(Guid processorID, string Number, out ProductManagement_DevlieryDetailModel m, out int value)
        {
            m = new ProductManagement_DevlieryDetailModel();
            string  sql0 = "select Guid,Name from T_ProductInfo_Product where Number='" + Number + "'";
            DataSet ds   = new DataSet();

            value = 0;
            decimal temp = 0;

            if (new Helper.SQLite.DBHelper().QueryData(sql0, out ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    m.ProductID = (Guid)dr["Guid"];
                    m.Name      = dr["Name"].ToString();
                }
                string sql1 = " SELECT " +
                              " total(a.Quantity) as QuantityB " +
                              " FROM " +
                              " T_Warehouse_SparePartsInventory a " +
                              " WHERE " +
                              " a.ProcessorID = '" + processorID + "' AND A.ProductID = '" + m.ProductID +
                              "' GROUP BY " +
                              " a.ProductID "
                ;
                object obj;
                new Helper.SQLite.DBHelper().QuerySingleResult(sql1, out obj);
                decimal.TryParse(obj.ToString(), out temp);
                value = decimal.ToInt32(temp);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        internal bool DeleteDetail(ProductManagement_DevlieryDetailModel m)
        {
            string sql = "update T_PM_ProductOutProcessDetail set DeleteMark='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' Where Guid='" + m.Guid + "'";

            return(new Helper.SQLite.DBHelper().SingleExecution(sql));
        }