Ejemplo n.º 1
0
        private void btnDeleteIngredient_Click(object sender, EventArgs e)
        {
            if (InventoryTable.SelectedRows.Count == 0)
            {
                return;
            }

            DialogResult dialogResult = MessageBox.Show(
                "آیا مطمئنید می خواهید " + InventoryTable.SelectedRows.Count.ToString() + " ماده اولیه را حذف کنید؟",
                "حذف ماده اولیه",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button2,
                MessageBoxOptions.RtlReading
                );

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            foreach (DataGridViewRow row in InventoryTable.SelectedRows)
            {
                FoodDB.DeleteIngredient(long.Parse(row.Cells[IngId.Index].Value.ToString()));
            }
            FillList();
        }
Ejemplo n.º 2
0
        private void OK_Click(object sender, EventArgs e)
        {
            double amount;
            bool   ValidNumber = double.TryParse(manualAmount.Text, out amount);

            manualAmount.BackColor = ValidNumber ? Color.White : Color.PaleVioletRed;

            if (!ValidNumber)
            {
                return;
            }

            int errorCode =
                FoodDB.AddIngredientChangeRecord(
                    id: ingredientToReport.id,
                    changeAmount: increase.Checked ? amount : -amount,
                    date: DateTime.Now);

            if (errorCode != 0)
            {
                MessageBox.Show(
                    text: "خطا در هنگام وارد کردن گزارش",
                    caption: "خطا",
                    buttons: MessageBoxButtons.OK,
                    icon: MessageBoxIcon.Exclamation,
                    defaultButton: MessageBoxDefaultButton.Button1,
                    options: MessageBoxOptions.RtlReading);
            }
            else
            {
                (Owner as ViewIngredientInventory).FillList();
                Close();
            }
        }
Ejemplo n.º 3
0
        private void btnDeleteFood_Click(object sender, EventArgs e)
        {
            if (FoodTable.SelectedRows.Count == 0)
            {
                return;
            }

            DialogResult dialogResult = MessageBox.Show(
                "آیا مطمئنید می خواهید " + FoodTable.SelectedRows.Count.ToString() + " غذا را حذف کنید؟",
                "حذف غذا",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button2,
                MessageBoxOptions.RtlReading
                );

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            foreach (DataGridViewRow row in FoodTable.SelectedRows)
            {
                FoodDB.DeleteFood(long.Parse(row.Cells[FoodId.Index].Value.ToString()));
            }
            FillList();
            FoodTable_RowEnter(null, null);
        }
Ejemplo n.º 4
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            if (!ControlsOK())
            {
                return;
            }
            if (IngToEdit == default)
            {
                MessageBox.Show("شمارنده ماده اولیه مقدار دهی نشده!",
                                "Ingredient ID",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1,
                                MessageBoxOptions.RtlReading
                                );
                return;
            }
            int errorCode = FoodDB.EditIngredient(
                id: IngToEdit.id,
                Name: IngName.Text,
                Scale: IngScale.Text,
                Quantity: float.Parse(IngQuantity.Text),
                ExpireDate: Converter.ToMiladi(IngExpireDate.Text)
                );

            if (errorCode == 0)
            {
                ViewIngredientInventory caller = (ViewIngredientInventory)Owner;
                caller.FillList();
                Close();
            }
        }
Ejemplo n.º 5
0
 private void listOfIngredients_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     if (isFilling)
     {
         return;
     }
     if (e.Item.Checked)
     {
         if (startDate.Text == "«شروع گزارش»" || endDate.Text == "«پایان گزارش»")
         {
             chart.Series.Add(FoodDB.GetIngredientReportChartAtMonth(long.Parse(e.Item.Tag.ToString()), DateTime.Now));
         }
         else
         {
             DateTime dateA, dateB;
             dateA = Converter.ToMiladi(startDate.Text);
             dateB = Converter.ToMiladi(endDate.Text);
             chart.Series.Add(FoodDB.GetIngredientReportChartA_B(long.Parse(e.Item.Tag.ToString()), dateA, dateB));
         }
     }
     else
     {
         chart.Series.Remove(chart.Series[e.Item.Text]);
     }
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public static DataSet listFood()
        {
            FoodDB  foodDB = new FoodDB();
            DataSet vals   = foodDB.listFoodDB();

            return(vals);
        }
Ejemplo n.º 8
0
        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();
            }
        }
Ejemplo n.º 9
0
        public void FillList()
        {
            FoodTable.Rows.Clear();

            List <object[]> FoodList = FoodDB.GetFoodList();

            foreach (object[] food in FoodList)
            {
                FoodTable.Rows.Add(food);
            }
        }
Ejemplo n.º 10
0
        public void FillList()
        {
            InventoryTable.Rows.Clear();
            List <object[]> IngList = FoodDB.GetIngredientList();

            foreach (var Ingredient in IngList)
            {
                int addedRow = InventoryTable.Rows.Add(Ingredient);
                if (InventoryTable.Rows[addedRow].Cells[2].Value.ToString().StartsWith("0"))
                {
                    InventoryTable.Rows[addedRow].DefaultCellStyle.BackColor = Color.Pink;
                }
            }
        }
Ejemplo n.º 11
0
        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();
            }
        }
Ejemplo n.º 12
0
        private void FillListOfIngredients()
        {
            isFilling = true;

            chart.Series.Clear();
            List <object[]> ingredients = FoodDB.GetIngredientList();

            foreach (var ing in ingredients)
            {
                listOfIngredients.Items.Add(text: ing[1 /*name*/].ToString()).Tag = ing[0 /*id*/].ToString();
            }

            isFilling = false;
        }
Ejemplo n.º 13
0
        private void btnEditFood_Click(object sender, EventArgs e)
        {
            if (FoodTable.CurrentRow == null)
            {
                return;
            }
            long FoodID = long.Parse(FoodTable.CurrentRow.Cells[FoodId.Index].Value.ToString());

            if (editFood == null || editFood.IsDisposed)
            {
                editFood       = new EditFood(FoodDB.GetFood(FoodID));
                editFood.Owner = this;
            }
            editFood.Show();
        }
Ejemplo n.º 14
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            if (!ControlsOK())
            {
                return;
            }
            int errorCode = FoodDB.AddIngredient(
                Name: IngName.Text,
                Scale: IngScale.Text,
                Quantity: float.Parse(IngQuantity.Text),
                ExpireDate: Converter.ToMiladi(IngExpireDate.Text)
                );

            if (errorCode == 0)
            {
                Close();
            }
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (!ControlsOK())
            {
                return;
            }
            int errorCode = FoodDB.AddFood(
                Name: FoodName.Text,
                Ingredients: RecipeString,
                SelfService: FoodSelfService.Checked,
                Category: FoodCategory.Text,
                Details: FoodDetails.Text
                );

            if (errorCode == 0)
            {
                Close();
            }
        }
Ejemplo n.º 17
0
        private void btnPrintFood_Click(object sender, EventArgs e)
        {
            if (FoodTable.SelectedRows.Count == 0)
            {
                return;
            }

            PrintDocument printDocument = new PrintDocument();

            printDocument.PrintPage += PrintDocument_PrintPage;
            foodToPrint              = FoodDB.GetFood(long.Parse(FoodTable.CurrentRow.Cells[FoodId.Index].Value.ToString()));

            PrintDialog printDialog = new PrintDialog();

            printDialog.ShowDialog(this);
            printDocument.PrinterSettings = printDialog.PrinterSettings;

            printDocument.Print();
        }
Ejemplo n.º 18
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (!ControlsOK())
            {
                return;
            }
            int errorCode = FoodDB.EditFood(
                id: FoodToEdit.Id,
                Name: FoodName.Text,
                Ingredients: RecipeString,
                SelfService: FoodSelfService.Checked,
                Category: FoodCategory.Text,
                Details: FoodDetails.Text
                );

            if (errorCode == 0)
            {
                ShowAllFood showAllFood = (ShowAllFood)Owner;
                showAllFood.FillList();
                showAllFood.FoodTable_RowEnter(null, null);
                Close();
            }
        }
Ejemplo n.º 19
0
 private void Awake()
 {
     slots.AddRange(transform.GetComponentsInChildren <FoodSlot>());
     db = FindObjectOfType <FoodDB>();
 }
Ejemplo n.º 20
0
 void Awake()
 {
     db = FindObjectOfType <FoodDB>();
 }
Ejemplo n.º 21
0
 private void AddFood_Load(object sender, EventArgs e)
 {
     FoodCategory.Items.AddRange(FoodDB.GetFoodCategories());
 }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
 private void Awake()
 {
     db             = FindObjectOfType <FoodDB>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }