public void GetPrintSetAndGoodSet(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }
            #region 这里做流程控制,在同一个线程中操作
            try
            {
                using (PrintSetServiceClient client = new PrintSetServiceClient())
                {
                    //2、获取打印配置
                    DataTable psdt = client.GetPrintSetByFPNum(text);

                    if (psdt == null || psdt.Rows.Count == 0)
                    {
                        Speecher("Print Config is null");
                        return;
                    }
                    //3、获取成品配置
                    DataTable gsdt = client.GetGoodSetByFPNum(text);
                    if (gsdt == null || gsdt.Rows.Count == 0)
                    {
                        Speecher("Goods Config is null");
                        return;
                    }
                    //4、获取Ro配置
                    DataTable rsdt = client.GetRoSetByFPNum(text);
                    if (rsdt == null || rsdt.Rows.Count == 0)
                    {
                        Speecher("Ro# Config is null");
                        return;
                    }
                    button4.BackColor = Color.Green;
                    List <PrintSet> printsetList = PrintSet.DataTableToList(psdt);
                    List <RoSet>    rosetList    = RoSet.DataTableToList(rsdt);
                    List <GoodSet>  goodsetList  = GoodSet.DataTableToList(gsdt);
                    _currentPrintSet    = null;
                    _currentPrintSet    = printsetList.OrderByDescending(p => p.CreateTime).First();
                    _currentRoSet       = null;
                    _currentRoSet       = rosetList.OrderByDescending(r => r.Oid).First();
                    _currentGoodSetList = null;
                    _currentGoodSetList = goodsetList;
                    GotoNextTextBox(FinishedProductNum);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("GetPrintSetAndGoodSet", ex);
            }
            #endregion
        }
 /// <summary>
 /// 添加/更新成品配置
 /// </summary>
 /// <param name="good"></param>
 private void InsertOrUpdateGoodSet(GoodSet good)
 {
     lock (lockObj)
     {
         try
         {
             if (good == null)
             {
                 MessageBox.Show("待添加/更新的记录为空", "Error");
             }
             StringBuilder            noQueryStrbd = new StringBuilder();
             List <SQLiteParameter[]> paramList    = new List <SQLiteParameter[]>();
             SQLiteParameter[]        parameter    =
             {
                 SQLiteHelper.MakeSQLiteParameter("@Oid",                DbType.Int32,  good.Oid),
                 SQLiteHelper.MakeSQLiteParameter("@FinishedProductNum", DbType.Int32,  good.FinishedProductNum),
                 SQLiteHelper.MakeSQLiteParameter("@MaterialNum",        DbType.String, good.MaterialNum),
                 SQLiteHelper.MakeSQLiteParameter("@MaterialName",       DbType.String, good.MaterialName),
                 SQLiteHelper.MakeSQLiteParameter("@QTY",                DbType.Int32,  good.QTY)
             };
             paramList.Add(parameter);
             if (good.Oid == 0)
             {
                 //添加新数据
                 noQueryStrbd.Append(@"Insert into GoodSet (FinishedProductNum,MaterialNum,MaterialName,QTY) ")
                 .Append(@"values ( ")
                 .Append(@"@FinishedProductNum,@MaterialNum,@MaterialName,@QTY ")
                 .Append(@")");
             }
             else
             {
                 //更新数据
                 noQueryStrbd.Append(@"Update GoodSet set FinishedProductNum=@FinishedProductNum,MaterialNum=@MaterialNum,MaterialName=@MaterialName,QTY=@QTY ")
                 .Append(@" WHERE Oid=@Oid");
             }
             new SQLiteHelper().ExecuteNonQueryBatch(noQueryStrbd.ToString(), paramList);
             InsertOrUpdateGoodSetCallBackDel del = InsertOrUpdateGoodSetCallBack;
             this.BeginInvoke(del);
             return;
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 /// <summary>
 /// 提交
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox3.Text))
     {
         MessageBox.Show("原材料号不可为空", "Warning");
         return;
     }
     #region 装载Good
     GoodSet good = new GoodSet();
     int     oid  = 0;
     good.Oid = int.TryParse(textBox1.Text.Trim(), out oid) ? oid : 0;
     int fpoid = 0;
     good.FinishedProductNum = int.TryParse(comboBox1.SelectedValue.ToString(), out fpoid) ? fpoid : 0;
     good.MaterialNum        = textBox3.Text.Trim();
     good.MaterialName       = textBox2.Text.Trim();
     good.QTY = Convert.ToInt32(numericUpDown1.Value);
     #endregion
     //InsertOrUpdateGoodSet(good);
     Task.Run(() => InsertOrUpdateGoodSet(good));
     return;
 }
예제 #4
0
        public void goodSetTest()
        {
            var g = new GoodSet();

            Assert.IsFalse(g.goodSet(new[] { 1, 2, 3 }));
            Assert.IsTrue(g.goodSet(new[] { 1, 2, 4 }));
            Assert.IsFalse(g.goodSet(new[] { 1, 2, 4, 6 }));
            Assert.IsTrue(g.goodSet(new[] { 1, 2, 4, 7 }));
            Assert.IsTrue(g.goodSet(new[] { 1, 3, 5, 7 }));
            Assert.IsTrue(g.goodSet(new[] { 0, 3, 6 }));
            Assert.IsTrue(g.goodSet(new[] { 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 }));
            Assert.IsFalse(g.goodSet(new[] { 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 }));
            Assert.IsTrue(g.goodSet(new[] { 2, 3, 4 }));
            Assert.IsFalse(g.goodSet(new[] { 2, 4, 6 }));
            Assert.IsTrue(g.goodSet(new[] { 3, 4, 6 }));
            Assert.IsTrue(g.goodSet(new[] { 5, 6, 7, 8, 9, 10 }));
            Assert.IsFalse(g.goodSet(new[] { 5, 6, 7, 8, 9, 10, 11 }));
            Assert.IsFalse(g.goodSet(new[] { 3, 4, 7, 11 }));
            Assert.IsFalse(g.goodSet(new[] { 2, 4, 7, 11 }));
            Assert.IsFalse(g.goodSet(new[] { 2, 4, 6, 7, 12 }));
            Assert.IsFalse(g.goodSet(new[] { 2, 4, 6, 12 }));
        }
 public Form_GoodEditor(GoodSet good)
 {
     InitializeComponent();
     _good = good;
 }