Exemplo n.º 1
0
 public EditForm(BathDBDataContext dc, StockIn stockin)
 {
     db = dc;
     inStock = stockin;
     InitializeComponent();
     stock.Items.AddRange(db.Stock.Select(x => x.name).ToArray());
     provider.Items.AddRange(db.Provider.Select(x => x.name).ToArray());
     goodsCat.Items.AddRange(db.GoodsCat.Select(x => x.name).ToArray());
     unit.Items.AddRange(db.Unit.Select(x => x.name).ToArray());
     var employees = db.Employee.Where(x => !db.Job.FirstOrDefault(y => y.id == x.jobId).name.Contains("技师"));
     checker.Items.AddRange(employees.Select(x => x.name).ToArray());
     transactor.Items.AddRange(employees.Select(x => x.name).ToArray());
     var stocktext = db.Stock.FirstOrDefault(x => x.id == stockin.stockId);
     stock.Text = stocktext !=null?stocktext.name:"";
     string nametext = stockin.name;
     name.Text = nametext != "" ? nametext : "";
     var goodCatext = db.GoodsCat.FirstOrDefault(y => y.id == db.StorageList.FirstOrDefault(x => x.name == stockin.name).goodsCatId);
     //MessageBox.Show("该商品没分类");
     goodsCat.Text = goodCatext != null ? goodCatext.name : "";
     string amouttext = stockin.amount.ToString();
     amount.Text = amouttext != "" ? amouttext : "";
     var providertext = db.Provider.FirstOrDefault(x => x.id == stockin.providerId);
     provider.Text = providertext != null ? providertext.name : "";
     string costtext = stockin.cost.ToString();
     cost.Text = costtext != "" ? costtext : "";
     string moneytext = stockin.money.ToString();
     money.Text = moneytext != "" ? moneytext : "";
     dtPickerIntoStock.Value = stockin.date != null ? stockin.date : DateTime.Now;
     string checkertext = stockin.checker;
     checker.Text = checkertext != "" ? checkertext : "";
     string transactortext=stockin.transactor;
     transactor.Text = transactortext != "" ? transactortext : "";
     string notetext = stockin.note;
     note.Text = notetext != "" ? notetext : "";
 }
Exemplo n.º 2
0
 //构造函数
 //public StockInForm(BathDBDataContext dc, IntoStockManagementForm form)
 public StockInForm(BathDBDataContext dc, StockIn _stockin)
 {
     db = dc;
     if (_stockin!=null)
     {
         stockin = _stockin;
         newStockin = false;
     }
     InitializeComponent();
     //m_Form = form;
 }
Exemplo n.º 3
0
 partial void DeleteStockIn(StockIn instance);
Exemplo n.º 4
0
 partial void UpdateStockIn(StockIn instance);
Exemplo n.º 5
0
 partial void InsertStockIn(StockIn instance);
Exemplo n.º 6
0
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (catId.Text == "")
            {
                BathClass.printErrorMsg("需要选择商品类别");
                return;
            }

            m_goods.name = name.Text.Trim();
            try
            {
                m_goods.minAmount = Convert.ToInt32(minAmount.Text.Trim());
            }
            catch
            {
                m_goods.minAmount = null;
            }
            m_goods.note = note.Text.Trim();
            m_goods.goodsCatId = db.GoodsCat.FirstOrDefault(x => x.name == catId.Text).id;

            if (newGoods)
            {
                if (db.StorageList.FirstOrDefault(x => x.name == m_goods.name) != null)
                {
                    BathClass.printErrorMsg("已经存在此名称的商品!");
                    name.SelectAll();
                    return;
                }
                db.StorageList.InsertOnSubmit(m_goods);
            }

            if (amount.Text.Trim() != "")
            {
                if (amount.Text.Trim() == "")
                {
                    BathClass.printErrorMsg("需要输入数量!");
                    return;
                }

                if (stock.Text == "")
                {
                    BathClass.printErrorMsg("需要选择仓库!");
                    return;
                }

                StockIn inStock = new StockIn();
                inStock.name = name.Text;
                if (cost.Text != "")
                    inStock.cost = Convert.ToDouble(cost.Text);
                inStock.amount = Convert.ToDouble(amount.Text);
                inStock.stockId = db.Stock.FirstOrDefault(x => x.name == stock.Text).id;
                inStock.note = stockNote.Text;
                inStock.date = DateTime.Now;
                inStock.transactor = LogIn.m_User.id;
                inStock.checker = LogIn.m_User.id;

                string unit_text = ComboUnit.Text.Trim();
                if (unit_text != "")
                {
                    inStock.unit = unit_text;
                    if (!db.Unit.Any(x=>x.name==unit_text))
                    {
                        var unit_instance = new Unit();
                        unit_instance.name = unit_text;
                        db.Unit.InsertOnSubmit(unit_instance);
                    }

                }

                if (money.Text.Trim() != "")
                    inStock.money = Convert.ToDouble(money.Text.Trim());
                db.StockIn.InsertOnSubmit(inStock);
            }
            db.SubmitChanges();
            if (newGoods)
            {
                name.Text = "";
                catId.SelectedIndex = -1;
                provider.SelectedIndex = -1;
                minAmount.Text = "";
                note.Text = "";
                cost.Text = "";
                amount.Text = "";
                stock.SelectedIndex = -1;
                stockNote.Text = "";
                money.Text = "";
                name.Focus();
                db.SubmitChanges();
                m_form.dgv_show();
                m_goods = new StorageList();
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemplo n.º 7
0
        //确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (!validateTextFields())
                return;

            StockIn inStock = new StockIn();
            inStock.name = name.Text;
            inStock.cost = Convert.ToDouble(cost.Text);
            inStock.amount = Convert.ToInt32(amount.Value);
            inStock.stockId = db.Stock.FirstOrDefault(x => x.name == stock.Text).id;
            inStock.note = note.Text;
            inStock.date = BathClass.Now(LogIn.connectionString);
            inStock.transactor = transactor.Text;
            inStock.checker = checker.Text;
            db.StockIn.InsertOnSubmit(inStock);

            //bool newSList = false;
            //var storage = db.StorageList.FirstOrDefault(x => x.name == name.Text && x.stockId == inStock.stockId);
            //if (storage == null)
            //{
            //    newSList = true;
            //    storage = new StorageList();
            //}

            //storage.name = name.Text;
            //storage.cost = inStock.cost;
            //storage.amountThisMonth = MConvert<int>.ToTypeOrDefault(storage.amountThisMonth) + inStock.amount;
            //storage.stockId = inStock.stockId;
            //if (newSList)
            //    db.StorageList.InsertOnSubmit(storage);

            db.SubmitChanges();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 8
0
        //确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (name.Text == "")
            {
                BathClass.printErrorMsg("需要选择商品名称");
                return;
            }

            if (amount.Text.Trim() == "")
            {
                BathClass.printErrorMsg("需要输入数量!");
                return;
            }

            if (stock.Text=="")
            {
                BathClass.printErrorMsg("需要选择仓库!");
                return;
            }

            if (transactor.Text=="")
            {
                BathClass.printErrorMsg("需要输入经手人!");
                return;
            }

            if (checker.Text=="")
            {
                BathClass.printErrorMsg("需要输入审核!");
                return;
            }

            if (provider.Text.Trim() == "")
            {
                BathClass.printErrorMsg("需要选择供应商!");
                return;
            }
            stockin.name = name.Text;
            stockin.cost = MConvert<double>.ToTypeOrDefault(cost.Text.Trim(), 0);
            stockin.amount = MConvert<double>.ToTypeOrDefault(amount.Text.Trim(),0);
            stockin.unit = unit.Text;
            stockin.stockId = db.Stock.FirstOrDefault(x => x.name == stock.Text).id;
            stockin.note = note.Text;
            stockin.date = dtPickerIntoStock.Value;
            stockin.transactor = transactor.Text;
            stockin.checker = checker.Text;
            stockin.money = totalmoney;

            //StockIn inStock = new StockIn();
            if (newStockin)
            {

            if (db.Unit.Where(x=>x.name==unit.Text.Trim()).Count()==0)
            {
                Unit u = new Unit();
                u.name = unit.Text.Trim();
                db.Unit.InsertOnSubmit(u);
                db.SubmitChanges();
            }

            var p = db.Provider.FirstOrDefault(x => x.name == provider.Text.Trim());
            if (p==null)
            {
                p = new Provider();
                p.name = provider.Text.Trim();
                var form = new ProviderForm(db, p);
                if (form.ShowDialog() != DialogResult.OK)
                    return;
                db.Provider.InsertOnSubmit(p);
                db.SubmitChanges();
            }
                stockin.providerId = p.id;
                db.StockIn.InsertOnSubmit(stockin);
            db.SubmitChanges();
                stockin = new StockIn();
                goodsCat.SelectedIndex = -1;
                name.Text = "";
                stock.SelectedIndex = -1;
                unit.Text = "";
                amount.Text = "";
                provider.SelectedIndex = -1;
                cost.Text = "";
                money.Text = "";
                checker.Text = "";
                transactor.Text = "";
                note.Text = "";
                checker.Text = LogIn.m_User.name;
                transactor.Text = LogIn.m_User.name;

            }
            else
            {
                db.SubmitChanges();
            this.DialogResult=DialogResult.OK;
                this.Close();
            }
        }