Пример #1
0
 private void toolSave_Click(object sender, EventArgs e)
 {
     if (getIntCount() == 1)
     {
         if (intFalg == 1)
         {
             try
             {
                 //退货
                 Sales model = SalesDAL.getEntryById <Sales, DateTime>(addtime);
                 if (model == null)
                 {
                     MessageBox.Show("记录不存在", "提示");
                 }
                 else if (model.Num - sales.Num < 0)
                 {
                     MessageBox.Show("退货数量超出销售数量", "提示");
                 }
                 else if (model.Num - sales.Num == 0)
                 {
                     //退货数量和销售数量一致,删除该销售记录
                     SalesDAL.DeleteEntry <Sales, DateTime>(model.AddTime);
                     LogInfoDAL.add(new LogInfo(0, 2, currentUser.EmpId, 3, model.Num, DateTime.Now));
                     MessageBox.Show("退货成功", "提示");
                     BinddgvData();
                 }
                 else
                 {
                     sales.Num = (model.Num - sales.Num);
                     SalesDAL.EditEntry <Sales>(sales, "AddTime");
                     LogInfoDAL.add(new LogInfo(0, 2, currentUser.EmpId, 2, (model.Num - sales.Num), DateTime.Now));
                     MessageBox.Show("退货成功", "提示");
                     BinddgvData();
                 }
                 intFalg = 0;
                 ClearControl();
                 ControlStaus();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("退货失败," + ex.Message, "提示");
             }
         }
     }
 }
Пример #2
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (getIntCount() == 1)
            {
                if (intFalg == 1)
                {
                    try
                    {
                        ReturnRet <int> result = StockDAL.QueryGoodsNum(sales.GoodsId, sales.Num);
                        if (result.success)
                        {
                            if (SalesDAL.add(sales))
                            {
                                LogInfoDAL.add(new LogInfo(0, 2, currentUser.EmpId, 1, sales.Num, sales.AddTime));
                                MessageBox.Show("添加成功", "提示");
                                BinddgvData();
                                intFalg = 0;

                                ClearControl();
                                ControlStaus();
                            }
                            else
                            {
                                MessageBox.Show("添加失败", "提示");
                            }
                        }
                        else
                        {
                            MessageBox.Show(result.message);
                            intFalg = 1;
                            txtSellGoodsNum.Text = result.data.ToString();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("添加失败," + ex.Message, "提示");
                    }
                }
                if (intFalg == 2)
                {
                    //修改
                    Sales model = SalesDAL.getEntryById <Sales, DateTime>(addtime);
                    if (model == null)
                    {
                        MessageBox.Show("记录不存在", "提示");
                    }
                    else
                    {
                        ReturnRet <int> result = StockDAL.QueryGoodsNum(sales.GoodsId, sales.Num);
                        if (result.success)
                        {
                            sales.AddTime = model.AddTime;
                            SalesDAL.EditEntry <Sales>(sales, "AddTime");
                            LogInfoDAL.add(new LogInfo(0, 2, currentUser.EmpId, 2, sales.Num - model.Num, DateTime.Now));
                            MessageBox.Show("修改成功", "提示");
                            BinddgvData();
                        }
                        else
                        {
                            MessageBox.Show(result.message);
                            txtSellGoodsNum.Text = result.data.ToString();
                            intFalg = 2;
                            return;
                        }
                    }
                    intFalg = 0;
                    ClearControl();
                    ControlStaus();
                }
                if (intFalg == 3)
                {
                    Sales model = SalesDAL.getEntryById <Sales, DateTime>(addtime);
                    if (model == null)
                    {
                        MessageBox.Show("记录不存在", "提示");
                    }
                    else
                    {
                        if (MessageBox.Show("确定删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            LogInfoDAL.add(new LogInfo(0, 2, currentUser.EmpId, 3, model.Num, DateTime.Now));
                            SalesDAL.DeleteEntry <Sales, DateTime>(model.AddTime);
                            MessageBox.Show("删除成功", "提示");
                            BinddgvData();
                        }
                    }

                    intFalg = 0;
                    ClearControl();
                    ControlStaus();
                }
            }
        }
Пример #3
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (getIntCount() == 1)
            {
                if (intFalg == 1)
                {
                    try
                    {
                        if (StockDAL.add(stock))
                        {
                            LogInfoDAL.add(new LogInfo(0, 1, currentUser.EmpId, 1, stock.Num, stock.AddTime));
                            MessageBox.Show("添加成功", "提示");
                            BinddgvData();
                        }
                        else
                        {
                            MessageBox.Show("添加失败", "提示");
                        }


                        intFalg = 0;

                        ClearControl();
                        ControlStaus();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("添加失败," + ex.Message, "提示");
                    }
                }
                if (intFalg == 2)
                {
                    //修改
                    Stock model = StockDAL.getEntryById <Stock, DateTime>(stock.AddTime);
                    if (model == null)
                    {
                        MessageBox.Show("记录不存在", "提示");
                    }
                    else
                    {
                        stock.AddTime = model.AddTime;
                        StockDAL.EditEntry <Stock>(stock, "AddTime");
                        LogInfoDAL.add(new LogInfo(0, 1, currentUser.EmpId, 2, stock.Num - model.Num, DateTime.Now));
                        MessageBox.Show("修改成功", "提示");
                        BinddgvData();
                    }
                    intFalg = 0;
                    ClearControl();
                    ControlStaus();
                }
                if (intFalg == 3)
                {
                    Stock model = StockDAL.getEntryById <Stock, DateTime>(stock.AddTime);
                    if (model == null)
                    {
                        MessageBox.Show("记录不存在", "提示");
                    }
                    else
                    {
                        if (MessageBox.Show("确定删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            LogInfoDAL.add(new LogInfo(0, 1, currentUser.EmpId, 3, model.Num, DateTime.Now));
                            StockDAL.DeleteEntry <Stock, DateTime>(model.AddTime);
                            MessageBox.Show("删除成功", "提示");
                            BinddgvData();
                        }
                    }

                    intFalg = 0;
                    ClearControl();
                    ControlStaus();
                }
            }
        }