Пример #1
0
 private void InitFood()
 {
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFood();
     foreach (Food food in foods)
     {
         dvFood.Rows.Add(food.foodid, food.cnName, food.enName, food.price, food.category,food.unit);
     }
 }
Пример #2
0
        private void FormUpdateFood_Load(object sender, EventArgs e)
        {
            FoodService service = new FoodService();
            Food food = service.GetFoodById(foodid);
            if (food != null)
            {
                tbCnName.Text = food.cnName;
                tbEnName.Text = food.enName;
                tbPrice.Text = food.price+"";
                cbUnit.Text = food.unit;
                cbCategory.Text = food.category;
                if (food.canDiscount.Equals("能"))
                {
                    rbCanDiscount.Checked = true;
                }
                else
                {
                    rbNoDiscount.Checked = true;
                }

                string savePath = @".\image\" + foodid + ".jpg";
                try
                {
                    pbImage.BackgroundImage = Image.FromFile(savePath);
                }
                catch
                {

                }
                if (food.isPlan.Equals("是"))
                {
                    cbIsPlan.Checked = true;
                    InitPlanFoodInfo();

                }
                else
                {
                    cbIsPlan.Checked = false;
                }
            }
        }
Пример #3
0
        private void AddFood()
        {
            string cnName = tbCnName.Text.Trim();
            string enName = tbEnName.Text.Trim();
            float price = 0.0f;
            try
            {
                price = float.Parse(tbPrice.Text.Trim());
            }
            catch
            {
                MessageBox.Show("价格必须是数字");
                return;
            }
            string unit = cbUnit.Text;
            string category = cbCategory.Text;
            if (cnName == "" || enName == "" || unit == "")
            {
                MessageBox.Show("餐点名称和单位不能为空");
                return;
            }
            Food food = new Food();
            food.canDiscount = "否";
            if (rbCanDiscount.Checked)
                food.canDiscount = "能";
            food.category = category;
            food.cnName = cnName;
            food.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            food.delTime = "";
            food.des = tbDes.Text.Trim();
            food.enName = enName;
            food.imageUpdateTime = "";
            food.isHot = "否";
            food.isPlan = "否";
            if (cbIsPlan.Checked)
            {
                food.isPlan = "是";
                // 添加套餐详情
                foreach (DataGridViewRow row in dvPlanInfo.Rows)
                {
                    PlanFood planFood = new PlanFood();
                    planFood.planFoodCount = Convert.ToInt32(row.Cells["foodcount"].Value);
                    planFood.planFoodid = Convert.ToInt32(row.Cells["foodid"].Value);
                    planFood.planFoodname = row.Cells["name"].Value.ToString();
                    planFood.planFoodPrice = float.Parse(row.Cells["foodprice"].Value.ToString());
                    planFood.planName = cnName;
                    planFood.planFoodUnit = row.Cells["foodUnit"].Value.ToString();
                    PlanFoodService planService = new PlanFoodService();
                    planService.AddPlanFood(planFood);
                }
            }
            food.needKC = "否";
            if (cbKC.Checked)
            {
                food.needKC = "是";

                // 添加库存信息
            }
            food.needMaterials = "否";
            if (cbMaterials.Checked)
            {
                food.needMaterials = "是";

                // 添加原材料信息
            }
            food.price = price;
            food.status = "库存";
            food.unit = unit;
            food.updateTime = "";
            FoodService service = new FoodService();
            int id = service.AddFood(food);
            if (imagePath != "")
            {
                string savePath = @".\image\" + id + ".jpg";
                ImageUtil.MakeThumbnail(imagePath, savePath, 500, 350, "H");
            }
            MessageBox.Show("新增餐点信息成功");
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Пример #4
0
 private void SearchFoodByName()
 {
     dvAllFood.Rows.Clear();
     string searchStr = tbFoodSearchStr.Text.Trim();
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(searchStr);
     foreach (Food food in foods)
     {
         dvAllFood.Rows.Add(food.foodid, food.cnName, food.enName, food.des, food.price, food.category, food.canDiscount, food.status, food.unit, food.isPlan, food.createTime, food.updateTime, food.imageUpdateTime, food.delTime, food.needKC, food.needMaterials);
     }
 }
Пример #5
0
 private void lbCount_Click(object sender, EventArgs e)
 {
     string dtb = dtFoodBegin.Value.ToString("yyyy-MM-dd 00:00:00");
     string dte = dtFoodEnd.Value.ToString("yyyy-MM-dd 00:00:00");
     FoodService service = new FoodService();
     DataTable dt = service.CountFood(dtb,dte);
     dvFoodcount.DataSource = dt;
 }
Пример #6
0
        private void FormOrder_Load(object sender, EventArgs e)
        {
            JudgeRights();
            lbTabInfo.Text = ("餐桌号--" + tabName);

            // 查询是否有账单信息 加载账单信息
            InitBillInfo();
            CalcBillMoney();
            FoodCategoryService service = new FoodCategoryService();
            List<FoodCategory> categorys = service.GetAllCategory();
            FoodService foodService = new FoodService();
            foreach (FoodCategory c in categorys)
            {
                TabPage page = new TabPage();
                page.Text = c.categoryName;
                List<Food> foods = foodService.GetAllFoodByCategory(c.categoryName);
                int width = tabCategory.Width;
                int height = tabCategory.Height;
                int lbWidth = width / 9;
                int lbHeight = height / 12;
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        int cco = i * 8 + j;
                        if (cco < foods.Count)
                        {
                            Label lb = new Label();
                            lb.Text = foods[cco].cnName;
                            lb.Tag = foods[cco].foodid;
                            lb.ForeColor = Color.White;
                            lb.BackColor = Color.LightGreen;
                            lb.TextAlign = ContentAlignment.MiddleCenter;
                            lb.BorderStyle = BorderStyle.FixedSingle;
                            //lb.AutoSize = false;
                            lb.Size = new Size(lbWidth, lbHeight);
                            lb.Location = new Point(10 + j * (int)(width / 8.2), 15 + i * height / 9);
                            lb.Click += lb_Click;
                            page.Controls.Add(lb);
                        }
                    }
                }

                tabCategory.TabPages.Add(page);
            }
        }
Пример #7
0
 private void SearchFood()
 {
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(tbSearch.Text.Trim());
     {
         pnFood.Controls.Clear();
         int width = tabCategory.Width;
         int height = tabCategory.Height;
         int lbWidth = width / 9;
         int lbHeight = height / 12;
         for (int i = 0; i < 8; i++)
         {
             for (int j = 0; j < 8; j++)
             {
                 int cco = i * 8 + j;
                 if (cco > 64)
                     return;
                 if (cco < foods.Count)
                 {
                     Label lb = new Label();
                     lb.Text = foods[cco].cnName;
                     lb.Tag = foods[cco].foodid;
                     lb.ForeColor = Color.White;
                     lb.BackColor = Color.LightGreen;
                     lb.TextAlign = ContentAlignment.MiddleCenter;
                     lb.BorderStyle = BorderStyle.FixedSingle;
                     //lb.AutoSize = false;
                     lb.Size = new Size(lbWidth, lbHeight);
                     lb.Location = new Point(10 + j * (int)(width / 8.2), 5 + i * height / 9);
                     lb.Click += lb_Click;
                     pnFood.Controls.Add(lb);
                 }
             }
         }
     }
 }
Пример #8
0
 void lb_Click(object sender, EventArgs e)
 {
     Label lb = (Label)sender;
     Food food = new FoodService().GetFoodById(Convert.ToInt32(lb.Tag));
     dvBill.Rows.Add("未确认",lb.Text,1,food.price,food.unit,"","否","否","否","",0);
     CalcBillMoney();
 }
Пример #9
0
 private void tbSearchStr_TextChanged(object sender, EventArgs e)
 {
     dvFood.Rows.Clear();
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(tbSearchStr.Text.Trim());
     foreach (Food food in foods)
     {
         dvFood.Rows.Add(food.foodid, food.cnName, food.enName, food.price, food.category, food.unit);
     }
 }