//确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (!validateTextFields())
                return;
            stockout.name = name.Text;
            stockout.amount = MConvert<double>.ToTypeOrDefault(amount.Text, 0);
            stockout.unit = ComboUnit.Text;
            stockout.stockId = db.Stock.FirstOrDefault(x => x.name == stock.Text).id;
            stockout.date = dtPickerIntoStock.Value;
            stockout.receiver = receiver.Text;
            stockout.transactor = transactor.Text;
            stockout.checker = checker.Text;
            stockout.note = note.Text;

            if (newStockout)
            {
                db.StockOut.InsertOnSubmit(stockout);
            string unit_txt = ComboUnit.Text.Trim();
            if (unit_txt != "")
            {
                if (!db.Unit.Any(x => x.name == unit_txt))
                {
                    var unit_instance = new Unit();
                    unit_instance.name = unit_txt;
                    db.Unit.InsertOnSubmit(unit_instance);
                }
            }
            db.SubmitChanges();
                stockout = new StockOut();
                goodsCat.SelectedIndex = -1;
                stock.SelectedIndex = -1;
                name.Text ="";
                amount.Text = "";
                ComboUnit.Text = "";
                receiver.Text = LogIn.m_User.name;
                transactor.Text = LogIn.m_User.name;
                checker.Text = LogIn.m_User.name;
                note.Text = "";
            }
            else
            {
                db.SubmitChanges();
            this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #2
0
        //确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (catgory.Text == "")
            {
                GeneralClass.printErrorMsg("需要选择类别!");
                return;
            }

            if (name.Text == "")
            {
                GeneralClass.printErrorMsg("需要输入名称!");
                return;
            }
            if (unit.Text == "")
            {
                GeneralClass.printErrorMsg("需要输入单位!");
                return;
            }

            m_menu.name = name.Text;
            m_menu.unit = unit.Text;
            m_menu.catgoryId = db.Catgory.FirstOrDefault(x => x.name == catgory.Text).id;
            m_menu.note = note.Text;
            m_menu.addAutomatic = addAutomatic.Checked;
            m_menu.waiter = waiter.Checked;
            m_menu.technician = technician.Checked;
            if (technician.Checked)
            {
                m_menu.techRatioType = techRatioType.Text;
                if (onRatio.Text == "" || orderRatio.Text == "")
                {
                    GeneralClass.printErrorMsg("需要输入提成比例!");
                    return;
                }
                m_menu.techRatioCat = techRatioCat.Text;
                m_menu.onRatio = Convert.ToDouble(onRatio.Text);
                m_menu.orderRatio = Convert.ToDouble(orderRatio.Text);
            }

            if (waiter.Checked)
            {
                if (waiterRatio.Text == "")
                {
                    GeneralClass.printErrorMsg("需要输入提成比例!");
                    return;
                }
                m_menu.waiterRatioType = waiterRatioType.SelectedIndex;
                m_menu.waiterRatio = Convert.ToDouble(waiterRatio.Text);
            }

            if (price.Text == "")
            {
                price.Focus();
                GeneralClass.printErrorMsg("需要输入价格!");
                return;
            }
            m_menu.price = Convert.ToDouble(price.Text);

            //if (timeLimitHour.Text == "" || timeLimitMiniute.Text == "")
            //{
            //    GeneralClass.printErrorMsg("需要输入数据!");
            //    return;
            //}

            if (addAutomatic.Checked)
            {
                if (addType.Text == "")
                {
                    GeneralClass.printErrorMsg("需要选择添加类型!");
                    return;
                }
                m_menu.timeLimitType = timeLimitType.Text;
                m_menu.addType = addType.Text;
                m_menu.timeLimitHour = Convert.ToInt32(timeLimitHour.Text);
                m_menu.timeLimitMiniute = Convert.ToInt32(timeLimitMiniute.Text);

                if (addType.SelectedIndex == 1)
                {
                    if (addMoney.Text == "")
                    {
                        GeneralClass.printErrorMsg("需要输入价格!");
                        return;
                    }
                    m_menu.addMoney = Convert.ToDouble(addMoney.Text);
                }
            }

            if (dgv.Rows.Count != 0)
            {
                m_menu.ResourceExpense = BathClass.assemble_Menu_resourceExpense(resourceExpense);
            }

            if (db.Unit.FirstOrDefault(x=>x.name==unit.Text)==null)
            {
                Unit newUnit = new Unit();
                newUnit.name = unit.Text;
                db.Unit.InsertOnSubmit(newUnit);
            }

            if (newMenu)
            {
                db.Menu.InsertOnSubmit(m_menu);
                db.SubmitChanges();
                m_Form.dgv_show();

                name.Text = "";
                catgory.Text = m_cat;
                price.Text = "";

                technician.Checked = false;
                techRatioType.SelectedIndex = 0;
                onRatio.Text = "";
                orderRatio.Text = "";

                timeLimitHour.Text = "0";
                timeLimitMiniute.Text = "0";
                addAutomatic.Checked = false;
                addType.Text = "";
                addType.Enabled = false;
                addMoney.Text = "10";
                addMoney.Enabled = false;
                note.Text = "";
                m_menu = new YouSoftBathGeneralClass.Menu();
                name.Focus();

                dgv.Rows.Clear();
                return;
            }
            else
            {
                db.SubmitChanges();
                this.DialogResult = DialogResult.OK;
            }
        }
 partial void DeleteUnit(Unit instance);
 partial void UpdateUnit(Unit instance);
 partial void InsertUnit(Unit instance);
Exemple #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();
            }
        }
        //确定
        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();
            }
        }