private void btnEditIngredient_Click(object sender, EventArgs e)
        {
            if (InventoryTable.SelectedRows.Count > 1)
            {
                DialogResult dialogResult = MessageBox.Show(
                    "آیا مطمئنید می خواهید " + InventoryTable.SelectedRows.Count.ToString() + " ماده اولیه را ویرایش کنید؟",
                    "ویرایش ماده اولیه",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2,
                    MessageBoxOptions.RtlReading
                    );
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }
            Ingredient ing;

            foreach (DataGridViewRow row in InventoryTable.SelectedRows)
            {
                ing = FoodDB.GetIngredient(long.Parse(row.Cells["IngId"].Value.ToString()));
                EditIngredients edit = new EditIngredients(ing);
                edit.Owner = this;
                edit.Show();
            }
        }
Beispiel #2
0
        public EditFood(Food FoodToEdit)
        {
            InitializeComponent();
            if (FoodToEdit == null)
            {
                Close();
            }

            FoodCategory.Items.AddRange(FoodDB.GetFoodCategories());

            this.FoodToEdit = FoodToEdit;
            FoodName.Text   = FoodToEdit.Name;

            FoodCategory.Text = FoodToEdit.Category;

            FoodSelfService.Checked = FoodToEdit.isSelfService;
            FoodDetails.Text        = FoodToEdit.Details;

            RecipeString = FoodToEdit.RecipeString;
            List <RecipeIngredient> ingredients = Converter.ToRecipeList(RecipeString);

            foreach (RecipeIngredient Ing in ingredients)
            {
                listIngredients.Items.Add(FoodDB.GetIngredient(Ing.IngId).name + " - " + Ing.IngAmount);
            }
        }
        private void btnChangeStock_Click(object sender, EventArgs e)
        {
            if (InventoryTable.SelectedRows.Count != 1)
            {
                return;
            }

            foreach (DataGridViewRow row in InventoryTable.SelectedRows)
            {
                changeStock       = new ChangeStock(FoodDB.GetIngredient(long.Parse(row.Cells[IngId.Index].Value.ToString())));
                changeStock.Owner = this;
                changeStock.Show();
            }
        }
Beispiel #4
0
        public void FoodTable_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (FoodTable.CurrentRow == null)
            {
                listIngredients.Items.Clear();
                return;
            }

            listIngredients.Items.Clear();

            string RecipeString = FoodTable.CurrentRow.Cells[FoodIngredients.Index].Value.ToString();
            List <RecipeIngredient> ingredients = Converter.ToRecipeList(RecipeString);

            foreach (RecipeIngredient Ing in ingredients)
            {
                listIngredients.Items.Add(FoodDB.GetIngredient(Ing.IngId).name + " - " + Ing.IngAmount + " " + Ing.IngScale);
            }
        }
Beispiel #5
0
        private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            // Create font and brush.
            Font FoodTitleFont    = new Font("B Titr", 18, FontStyle.Regular, GraphicsUnit.Point);
            Font FoodCategoryFont = new Font("B Karim", 14, FontStyle.Bold, GraphicsUnit.Point);
            Font IngredientsFont  = new Font("B Mitra", 12, FontStyle.Bold, GraphicsUnit.Point);
            Font IngFont          = new Font("B Nazanin", 12, FontStyle.Regular, GraphicsUnit.Point);

            SolidBrush drawBrush = new SolidBrush(Color.Black);

            // Create rectangle for drawing.
            RectangleF titleRect = new RectangleF(
                x: e.MarginBounds.Right - TextRenderer.MeasureText(foodToPrint.Name, FoodTitleFont).Width,
                y: e.MarginBounds.Top,
                width: TextRenderer.MeasureText(foodToPrint.Name, FoodTitleFont).Width + 10.0f,
                height: TextRenderer.MeasureText("ل", FoodTitleFont).Height
                );
            RectangleF categoryRect = new RectangleF(
                x: titleRect.Left + TextRenderer.MeasureText(foodToPrint.Category, FoodCategoryFont).Width / 2,
                y: titleRect.Bottom + 2.0f,
                width: TextRenderer.MeasureText(foodToPrint.Category, FoodCategoryFont).Width,
                height: TextRenderer.MeasureText("ل", FoodCategoryFont).Height
                );
            RectangleF ingredientsRect = new RectangleF(
                x: titleRect.X,    // Center
                y: categoryRect.Bottom + 3.0f,
                width: TextRenderer.MeasureText("مواد لازم:", IngredientsFont).Width,
                height: TextRenderer.MeasureText("ل", IngredientsFont).Height
                );
            RectangleF ingsRect = new RectangleF(
                x: e.MarginBounds.Left,
                y: ingredientsRect.Bottom + 2.0f,
                width: ingredientsRect.Right - e.MarginBounds.Left,
                height: e.MarginBounds.Bottom - (ingredientsRect.Bottom + 20.0f)
                );
            string     todayShamsi = "تاریخ: " + Converter.ToShamsi(DateTime.Now);
            RectangleF dateRect    = new RectangleF(
                x: e.MarginBounds.Left,
                y: e.MarginBounds.Top,
                width: TextRenderer.MeasureText(todayShamsi, IngredientsFont).Width + 5,
                height: TextRenderer.MeasureText(todayShamsi, IngredientsFont).Height
                );
            RectangleF detailsRect = new RectangleF(
                x: dateRect.Right,
                y: titleRect.Y + 2.0f,
                width: titleRect.Left - dateRect.Right,
                height: titleRect.Height
                );

            // Set format of string.
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment   = StringAlignment.Near;
            drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;

            // Draw string to the page.
            e.Graphics.DrawString(foodToPrint.Name, FoodTitleFont, drawBrush, titleRect, drawFormat);
            e.Graphics.DrawString(foodToPrint.Category, FoodCategoryFont, drawBrush, categoryRect, drawFormat);
            e.Graphics.DrawString("مواد لازم:", IngredientsFont, drawBrush, ingredientsRect, drawFormat);

            // Print recipe one by one for each ingredient.
            List <RecipeIngredient> Recipe = Converter.ToRecipeList(foodToPrint.RecipeString);

            rLine = "";
            foreach (RecipeIngredient Ing in Recipe)
            {
                rLine += FoodDB.GetIngredient(Ing.IngId).name + " - " + Ing.IngAmount + " " + Ing.IngScale + "\n";
            }
            e.Graphics.DrawString(rLine, IngFont, drawBrush, ingsRect, drawFormat);
            e.Graphics.DrawString(todayShamsi, IngredientsFont, drawBrush, dateRect, drawFormat);
            e.Graphics.DrawString(foodToPrint.Details, FoodCategoryFont, drawBrush, detailsRect, drawFormat);
        }