Пример #1
0
        public RptFoodDetails(FoodDetailsModel foodDetailsModels)
        {
            //Create new CultureInfo
            var cultureInfo = new System.Globalization.CultureInfo("fa-IR");

            // Set the language for static text (i.e. column headings, titles)
            System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

            // Set the language for dynamic text (i.e. date, time, money)
            System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;

            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
            objectDataSource2.DataSource = foodDetailsModels.FoodMaterialsModel;
            objectDataSource1.DataSource = foodDetailsModels.FoodSurplusPrices;
            table2.DataSource            = foodDetailsModels.FoodSurplusPrices;
            textBox28.Value = foodDetailsModels.FoodName;
            textBox9.Value  = foodDetailsModels.FoodMaterials.Sum(a => a.MaterialTotalPrice).ToString("c0", cultureInfo);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var food = (Data.Food)cmbFoodName.SelectedItem;

            if (int.Parse(numericTextBox1.Value) == 0 || int.Parse(numericTextBox1.Value) < 0)
            {
                RtlMessageBox.Show("تعداد نمیتواند صفر باشد");
                return;
            }

            var finalprice = food.FoodSurplusPrices.Where(a => a.AdjustKind == 8).Select(a => a.Price).First() *
                             int.Parse(numericTextBox1.Value);
            FoodDetailsModel items = new FoodDetailsModel()
            {
                FoodId        = food.Id,
                FoodName      = food.FoodName,
                MaterialPrice = food.FoodSurplusPrices.Where(a => a.AdjustKind == 8).Select(a => a.Price)
                                .FirstOrDefault(),
                Quantity   = int.Parse(numericTextBox1.Value),
                FinalPrice = finalprice
            };

            for (int i = 0; i < dataGridView1.RowCount; i++) //compare data
            {
                var Row = dataGridView1.Rows[i];
                var abc = Row.Cells[0].Value;
                if (abc.ToString() == items.FoodId.ToString())
                {
                    RtlMessageBox.Show("رکورد تکراری می باشد");
                    return;
                }
            }

            _listFoodDetail.Add(items);
            dataGridView1.AutoGenerateColumns = false;

            dataGridView1.DataSource = _listFoodDetail;
        }
Пример #3
0
        /// <summary>
        /// مشخصات یک پرس غذا
        /// </summary>
        /// <param name="foodId"></param>
        /// <returns></returns>
        public Telerik.Reporting.Report GetFoodDetail(int foodId)
        {
            using (var db = new UnitOfWork())
            {
                var food = db.FoodService.GetOne(foodId);

                var model = new FoodDetailsModel()
                {
                    FoodId            = food.Id,
                    FoodName          = food.FoodName,
                    FoodMaterials     = food.FoodMaterials,
                    FoodSurplusPrices = food.FoodSurplusPrices.ToList()
                };



                foreach (var matetrial in food.FoodMaterials)
                {
                    var foodMaterialModel = new FoodMaterialModel()
                    {
                        MaterialName = matetrial.MaterialPrice.Material.MaterialName,
                        Price        = matetrial.UnitPrice,
                        Quantity     = matetrial.Quantity,
                        TotalPrice   = matetrial.MaterialTotalPrice,
                    };
                    model.FoodMaterialsModel.Add(foodMaterialModel);
                }
                return(new RptFoodDetails(model));
            }
            //var list = new List<FoodDetailsModel>();
            //using (var db = new UnitOfWork())
            //{

            //    List<Data.Food> foods = db.FoodService.GetAll().ToList();

            //    foreach (var food in foods)
            //    {
            //        var model = new FoodDetailsModel()
            //        {
            //            FoodId = food.Id,
            //            FoodName = food.FoodName,
            //            FoodMaterials = new List<FoodMaterialModel>(),
            //            FoodSurplusPrices = food.FoodSurplusPrices as List<FoodSurplusPrice>
            //        };
            //        foreach (var matetrial in food.FoodMaterials)
            //        {
            //            var foodMaterialModel = new FoodMaterialModel()
            //            {
            //                MaterialName = matetrial.Material.MaterialName,
            //                Price = matetrial.UnitPrice,
            //                Quantity = matetrial.Quantity,
            //                TotalPrice = matetrial.MaterialTotalPrice,

            //            };
            //            model.FoodMaterials.Add(foodMaterialModel);
            //        }

            //        list.Add(model);
            //    }
            //}

            //return new MasterReport(list);
        }