Esempio n. 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            #region General Services
            UnitofWork unitofWork = new UnitofWork(ctx);
            DailyCastingEntry_TotalRevenue_Service dailyCastingEntry_TotalRevenue_Service = new DailyCastingEntry_TotalRevenue_Service(unitofWork);
            #endregion

            if (DailyCastingEntryType == 1)
            {
                DateTime CastingDate = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                decimal  Price       = nudPrice.Value;
                string   Desciptions = txtDesciptions.Text;
                if (Price > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        DailyCastingEntry_Personal_Service dailyCastingEntry_Personal_Service = new DailyCastingEntry_Personal_Service(unitofWork);
                        DailyCastingEntry_Personal         dailyCastingEntry_Personal         = new DailyCastingEntry_Personal
                        {
                            CastingDate  = CastingDate,
                            Status       = Status.Active,
                            Price        = Price,
                            Descriptions = Desciptions
                        };

                        if (dailyCastingEntry_Personal_Service.Insert(dailyCastingEntry_Personal))
                        {
                            DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(CastingDate);
                            if (dailyCastingEntry_TotalRevenue != null)
                            {
                                if (dailyCastingEntry_TotalRevenue.Personal_ReelPrice > 0)
                                {
                                    dailyCastingEntry_TotalRevenue.Personal_ReelPrice  += Price;
                                    dailyCastingEntry_TotalRevenue.Personal_TotalPrice += Price;
                                }
                                else
                                {
                                    dailyCastingEntry_TotalRevenue.Personal_ReelPrice  = Price;
                                    dailyCastingEntry_TotalRevenue.Personal_TotalPrice = Price;
                                }

                                if (dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                DailyCastingEntry_TotalRevenue newDailyCastingEntry_TotalRevenue = new DailyCastingEntry_TotalRevenue
                                {
                                    Personal_ReelPrice  = Price,
                                    Personal_TotalPrice = Price,
                                    Status      = Status.Active,
                                    CastingDate = CastingDate
                                };
                                if (dailyCastingEntry_TotalRevenue_Service.Insert(newDailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            nudPrice.Value      = 0;
                            txtDesciptions.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("Hata Oluştu.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (DailyCastingEntryType == 2)
            {
                #region Variables
                DateTime CastingDate    = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                decimal  Price          = nudPrice.Value;
                int      NumberOfPeople = Convert.ToInt32(nudNumberOfPeope.Value);
                string   CateringCode   = cmbCateringCustomer.SelectedValue.ToString();
                string   PaymentMade    = cmbCateringPayment.Text;
                string   InvoiceCut     = cmbCateringInvoice.Text;
                #endregion

                #region Service Instance
                CateringCompanies_Service          cateringCompanies_Service          = new CateringCompanies_Service(unitofWork);
                DailyCastingEntry_Catering_Service dailyCastingEntry_Catering_Service = new DailyCastingEntry_Catering_Service(unitofWork);
                #endregion

                if (Price > 0 && NumberOfPeople > 0 && !string.IsNullOrEmpty(CateringCode) && !string.IsNullOrEmpty(cmbCateringInvoice.Text) && !string.IsNullOrEmpty(cmbCateringPayment.Text))
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        DailyCastingEntry_Catering dailyCastingEntry_Catering = new DailyCastingEntry_Catering()
                        {
                            CastingDate     = CastingDate,
                            CompanyCode     = cateringCompanies_Service.GetCateringCompanies(CateringCode).Code,
                            CateringCompany = cateringCompanies_Service.GetCateringCompanies(CateringCode).Name,
                            NumberOfPeople  = NumberOfPeople,
                            Price           = Price,
                            Status          = Status.Active,
                            PaymentMade     = PaymentMade,
                            InvoiceCut      = InvoiceCut
                        };
                        if (dailyCastingEntry_Catering_Service.Insert(dailyCastingEntry_Catering))
                        {
                            DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(CastingDate);
                            if (dailyCastingEntry_TotalRevenue != null)
                            {
                                if (PaymentMade == "Yapıldı")
                                {
                                    dailyCastingEntry_TotalRevenue.Catering_ReelPrice = dailyCastingEntry_TotalRevenue.Catering_ReelPrice > 0 ? dailyCastingEntry_TotalRevenue.Catering_ReelPrice + Price : Price;
                                }
                                dailyCastingEntry_TotalRevenue.Catering_TotalPrice = dailyCastingEntry_TotalRevenue.Catering_TotalPrice > 0 ? dailyCastingEntry_TotalRevenue.Catering_TotalPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.Catering_NumberOfPeople = dailyCastingEntry_TotalRevenue.Catering_NumberOfPeople > 0 ? dailyCastingEntry_TotalRevenue.Catering_NumberOfPeople + NumberOfPeople : NumberOfPeople;

                                if (dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                #region DailyCastingEntry_TotalRevenue Yeni Kayıt Oluşturuluyor ve Catering Bilgileri Ekleniyor.
                                dailyCastingEntry_TotalRevenue = new DailyCastingEntry_TotalRevenue
                                {
                                    CastingDate             = CastingDate,
                                    Catering_NumberOfPeople = NumberOfPeople,
                                    Catering_TotalPrice     = Price,
                                    Catering_ReelPrice      = PaymentMade == "Yapıldı" ? Price : 0
                                };

                                if (dailyCastingEntry_TotalRevenue_Service.Insert(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı.");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                #endregion
                            }

                            nudPrice.Value                    = 0;
                            nudNumberOfPeope.Value            = 0;
                            cmbCateringCustomer.SelectedIndex = 0;
                        }
                        else
                        {
                            MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (DailyCastingEntryType == 3)
            {
                #region Variables
                var CateringCustomerCode = cmbCateringCustomer.SelectedValue.ToString();
                #endregion

                #region Service Instance
                CateringCompanies_Service          cateringCompanies_Service          = new CateringCompanies_Service(unitofWork);
                DailyCastingEntry_Catering_Service dailyCastingEntry_Catering_Service = new DailyCastingEntry_Catering_Service(unitofWork);
                #endregion

                if (checkedListBox.CheckedItems.Count > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        for (int i = 0; i < checkedListBox.CheckedItems.Count; i++)
                        {
                            DateTime Date  = Convert.ToDateTime(checkedListBox.CheckedItems[i].ToString().Split('(')[0].Trim());
                            decimal  Price = Convert.ToDecimal(checkedListBox.CheckedItems[i].ToString().Split(':')[1].Replace(")", "").Trim());

                            List <DailyCastingEntry_Catering> dailyCastingEntry_CateringList = dailyCastingEntry_Catering_Service.GetAllCateringPaymentCasting().Where(x => x.CastingDate == Date && x.CompanyCode == CateringCustomerCode && x.Price == Price && x.PaymentMade == "Yapılmadı").ToList();
                            if (dailyCastingEntry_CateringList.Count > 0)
                            {
                                dailyCastingEntry_CateringList[0].PaymentMade = "Yapıldı";
                                if (dailyCastingEntry_Catering_Service.Update(dailyCastingEntry_CateringList[0]))
                                {
                                    DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(Date);
                                    if (dailyCastingEntry_TotalRevenue != null)
                                    {
                                        dailyCastingEntry_TotalRevenue.Catering_ReelPrice = dailyCastingEntry_TotalRevenue.Catering_ReelPrice > 0 ? dailyCastingEntry_TotalRevenue.Catering_ReelPrice + dailyCastingEntry_CateringList[0].Price : dailyCastingEntry_CateringList[0].Price;

                                        dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue);
                                    }
                                }
                            }
                            MessageBox.Show("İşlem Başarılı");
                            checkedListBox.Items.Clear();
                            var CateringCode = cmbCateringCustomer.SelectedValue.ToString();
                            List <DailyCastingEntry_Catering> dailyCastingEntry_Caterings = dailyCastingEntry_Catering_Service.GetAllCateringPaymentCasting().Where(x => x.CompanyCode == CateringCode && x.PaymentMade == "Yapılmadı").ToList();
                            if (dailyCastingEntry_Caterings.Count > 0)
                            {
                                dailyCastingEntry_Caterings.ForEach(x =>
                                {
                                    checkedListBox.Items.Add(string.Format("{0: dd/MM/yyyy}", x.CastingDate) + " ( Tutar: " + x.Price + " )");
                                });
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else if (DailyCastingEntryType == 4)
            {
                #region Variables
                DateTime CastingDate    = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                decimal  Price          = nudPrice.Value;
                int      NumberOfPeople = Convert.ToInt32(nudNumberOfPeope.Value);
                #endregion

                if (Price > 0 && NumberOfPeople > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        DailyCastingEntry_Restaurant_Cash dailyCastingEntry_Restaurant_Cash = new DailyCastingEntry_Restaurant_Cash()
                        {
                            CastingDate    = CastingDate,
                            NumberOfPeople = NumberOfPeople,
                            Price          = Price,
                            Status         = Status.Active
                        };
                        DailyCastingEntry_Restaurant_Cash_Service dailyCastingEntry_Restaurant_Cash_Service = new DailyCastingEntry_Restaurant_Cash_Service(unitofWork);
                        if (dailyCastingEntry_Restaurant_Cash_Service.Insert(dailyCastingEntry_Restaurant_Cash))
                        {
                            DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(CastingDate);
                            if (dailyCastingEntry_TotalRevenue != null)
                            {
                                dailyCastingEntry_TotalRevenue.RestaurantCash_ReelPrice = dailyCastingEntry_TotalRevenue.RestaurantCash_ReelPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantCash_ReelPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantCash_TotalPrice = dailyCastingEntry_TotalRevenue.RestaurantCash_TotalPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantCash_TotalPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantCash_NumberOfPeople = dailyCastingEntry_TotalRevenue.RestaurantCash_NumberOfPeople > 0 ? dailyCastingEntry_TotalRevenue.RestaurantCash_NumberOfPeople + NumberOfPeople : NumberOfPeople;

                                if (dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                #region DailyCastingEntry_TotalRevenue Yeni Kayıt Oluşturuluyor ve Catering Bilgileri Ekleniyor.
                                dailyCastingEntry_TotalRevenue = new DailyCastingEntry_TotalRevenue
                                {
                                    RestaurantCash_NumberOfPeople = NumberOfPeople,
                                    RestaurantCash_TotalPrice     = Price,
                                    RestaurantCash_ReelPrice      = Price,
                                    CastingDate = CastingDate
                                };

                                if (dailyCastingEntry_TotalRevenue_Service.Insert(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                #endregion
                            }

                            nudNumberOfPeope.Value = 0;
                            nudPrice.Value         = 0;
                        }
                        else
                        {
                            MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (DailyCastingEntryType == 5)
            {
                #region Variables
                DateTime CastingDate    = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                string   BankName       = cmbBanks.Text;
                string   BankCode       = cmbBanks.SelectedValue.ToString();
                decimal  Price          = nudPrice.Value;
                int      NumberOfPeople = Convert.ToInt32(nudNumberOfPeope.Value);
                #endregion

                #region Services
                Banks_Service banks_Service = new Banks_Service(unitofWork);
                DailyCastingEntry_Restaurant_Bank_Service dailyCastingEntry_Restaurant_Bank_Service = new DailyCastingEntry_Restaurant_Bank_Service(unitofWork);
                #endregion

                if (!string.IsNullOrEmpty(BankCode) && Price > 0 && NumberOfPeople > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Banks banks = banks_Service.GetBanks(BankCode);
                        DailyCastingEntry_Restaurant_Bank dailyCastingEntry_Restaurant_Bank = new DailyCastingEntry_Restaurant_Bank()
                        {
                            BankName       = banks.BankName,
                            BankCode       = banks.BankCode,
                            CastingDate    = CastingDate,
                            NumberOfPeople = NumberOfPeople,
                            Price          = Price,
                            Status         = Status.Active
                        };
                        if (dailyCastingEntry_Restaurant_Bank_Service.Insert(dailyCastingEntry_Restaurant_Bank))
                        {
                            DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(CastingDate);
                            if (dailyCastingEntry_TotalRevenue != null)
                            {
                                dailyCastingEntry_TotalRevenue.RestaurantBank_ReelPrice = dailyCastingEntry_TotalRevenue.RestaurantBank_ReelPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantBank_ReelPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantBank_TotalPrice = dailyCastingEntry_TotalRevenue.RestaurantBank_TotalPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantBank_TotalPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantBank_NumberOfPeople = dailyCastingEntry_TotalRevenue.RestaurantBank_NumberOfPeople > 0 ? dailyCastingEntry_TotalRevenue.RestaurantBank_NumberOfPeople + NumberOfPeople : NumberOfPeople;

                                if (dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                dailyCastingEntry_TotalRevenue = new DailyCastingEntry_TotalRevenue
                                {
                                    RestaurantBank_NumberOfPeople = NumberOfPeople,
                                    RestaurantBank_TotalPrice     = Price,
                                    RestaurantBank_ReelPrice      = Price,
                                    CastingDate = CastingDate
                                };

                                if (dailyCastingEntry_TotalRevenue_Service.Insert(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            };

                            cmbBanks.SelectedIndex = 0;
                            nudPrice.Value         = 0;
                            nudNumberOfPeope.Value = 0;
                        }
                        else
                        {
                            MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (DailyCastingEntryType == 6)
            {
                #region Variables
                DateTime CastingDate    = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                string   Name           = cmbFoods.Text;
                string   Code           = cmbFoods.SelectedValue.ToString();
                decimal  Price          = nudPrice.Value;
                int      NumberOfPeople = Convert.ToInt32(nudNumberOfPeope.Value);
                #endregion

                #region Services
                FoodCards_Service foodCards_Service = new FoodCards_Service(unitofWork);
                DailyCastingEntry_Restaurant_Food_Service dailyCastingEntry_Restaurant_Food_Service = new DailyCastingEntry_Restaurant_Food_Service(unitofWork);
                #endregion

                if (!string.IsNullOrEmpty(Code) && Price > 0 && NumberOfPeople > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        FoodCards foodCards = foodCards_Service.GetFoodCards(Code);
                        DailyCastingEntry_Restaurant_Food dailyCastingEntry_Restaurant_Food = new DailyCastingEntry_Restaurant_Food()
                        {
                            FoodCardCode   = foodCards.Code,
                            FoodCardName   = foodCards.Name,
                            CastingDate    = CastingDate,
                            NumberOfPeople = NumberOfPeople,
                            Price          = Price,
                            Status         = Status.Active
                        };
                        if (dailyCastingEntry_Restaurant_Food_Service.Insert(dailyCastingEntry_Restaurant_Food))
                        {
                            DailyCastingEntry_TotalRevenue dailyCastingEntry_TotalRevenue = dailyCastingEntry_TotalRevenue_Service.GetTotalRevenue(CastingDate);
                            if (dailyCastingEntry_TotalRevenue != null)
                            {
                                dailyCastingEntry_TotalRevenue.RestaurantFood_ReelPrice = dailyCastingEntry_TotalRevenue.RestaurantFood_ReelPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantFood_ReelPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantFood_TotalPrice = dailyCastingEntry_TotalRevenue.RestaurantFood_TotalPrice > 0 ? dailyCastingEntry_TotalRevenue.RestaurantFood_TotalPrice + Price : Price;

                                dailyCastingEntry_TotalRevenue.RestaurantFood_NumberOfPeople = dailyCastingEntry_TotalRevenue.RestaurantFood_NumberOfPeople > 0 ? dailyCastingEntry_TotalRevenue.RestaurantFood_NumberOfPeople + NumberOfPeople : NumberOfPeople;

                                if (dailyCastingEntry_TotalRevenue_Service.Update(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                dailyCastingEntry_TotalRevenue = new DailyCastingEntry_TotalRevenue
                                {
                                    RestaurantFood_NumberOfPeople = NumberOfPeople,
                                    RestaurantFood_TotalPrice     = Price,
                                    RestaurantFood_ReelPrice      = Price,
                                    CastingDate = CastingDate
                                };

                                if (dailyCastingEntry_TotalRevenue_Service.Insert(dailyCastingEntry_TotalRevenue))
                                {
                                    MessageBox.Show("İşlem Başarılı");
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            cmbFoods.SelectedIndex = 0;
                            nudPrice.Value         = 0;
                            nudNumberOfPeope.Value = 0;
                        }
                        else
                        {
                            MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 2
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            EnumHelper enumHelper = new EnumHelper();
            UnitofWork unitofWork = new UnitofWork(ctx);
            DailyCastingEntry_Restaurant_Bank_Service dailyCastingEntry_Restaurant_Bank_Service = new DailyCastingEntry_Restaurant_Bank_Service(unitofWork);
            DailyCastingEntry_Restaurant_Cash_Service dailyCastingEntry_Restaurant_Cash_Service = new DailyCastingEntry_Restaurant_Cash_Service(unitofWork);
            DailyCastingEntry_Restaurant_Food_Service dailyCastingEntry_Restaurant_Food_Service = new DailyCastingEntry_Restaurant_Food_Service(unitofWork);

            List <DailyCastingEntry_Restaurant_Bank> dailyCastingEntry_Restaurant_Bank_List   = dailyCastingEntry_Restaurant_Bank_Service.GetAllRestaurantBanksPaymentCasting();
            List <DailyCastingEntry_Restaurant_Cash> dailyCastingEntry_Restaurant_Cashes_List = dailyCastingEntry_Restaurant_Cash_Service.GetAllRestaurantCashPaymentCasting();
            List <DailyCastingEntry_Restaurant_Food> dailyCastingEntry_Restaurant_Foods_List  = dailyCastingEntry_Restaurant_Food_Service.GetAllRestaurantFoodPaymentCasting();

            List <RestaurantRevenueVM> restaurantRevenueVMs = new List <RestaurantRevenueVM>();

            dailyCastingEntry_Restaurant_Bank_List.ForEach(x =>
            {
                RestaurantRevenueVM restaurantRevenueVM = new RestaurantRevenueVM();
                restaurantRevenueVM.CastingDate         = x.CastingDate;
                restaurantRevenueVM.PaymentType         = enumHelper.GetEnumDescription(PaymentType.CreditCard);
                restaurantRevenueVM.Name           = x.BankName;
                restaurantRevenueVM.NumberOfPeople = x.NumberOfPeople;
                restaurantRevenueVM.Price          = x.Price;
                restaurantRevenueVMs.Add(restaurantRevenueVM);
            });

            dailyCastingEntry_Restaurant_Cashes_List.ForEach(x =>
            {
                RestaurantRevenueVM restaurantRevenueVM = new RestaurantRevenueVM();
                restaurantRevenueVM.CastingDate         = x.CastingDate;
                restaurantRevenueVM.PaymentType         = enumHelper.GetEnumDescription(PaymentType.Cash);
                restaurantRevenueVM.Name           = "";
                restaurantRevenueVM.NumberOfPeople = x.NumberOfPeople;
                restaurantRevenueVM.Price          = x.Price;
                restaurantRevenueVMs.Add(restaurantRevenueVM);
            });

            dailyCastingEntry_Restaurant_Foods_List.ForEach(x =>
            {
                RestaurantRevenueVM restaurantRevenueVM = new RestaurantRevenueVM();
                restaurantRevenueVM.CastingDate         = x.CastingDate;
                restaurantRevenueVM.PaymentType         = enumHelper.GetEnumDescription(PaymentType.FoodCard);;
                restaurantRevenueVM.Name           = x.FoodCardName;
                restaurantRevenueVM.NumberOfPeople = x.NumberOfPeople;
                restaurantRevenueVM.Price          = x.Price;
                restaurantRevenueVMs.Add(restaurantRevenueVM);
            });
            dataGridView1.DataSource = restaurantRevenueVMs;

            dataGridView1.Columns[0].HeaderText = "Tarih";
            dataGridView1.Columns[1].HeaderText = "Ödeme Tipi";
            dataGridView1.Columns[2].HeaderText = "Kart Adı";
            dataGridView1.Columns[3].HeaderText = "Kişi Sayısı";
            dataGridView1.Columns[4].HeaderText = "Tutar";

            Tools tools = new Tools();

            tools.DataGridViewResize(dataGridView1, 5);

            txtRealRevenues.Text  = restaurantRevenueVMs.Sum(x => x.Price).ToString();
            txtTotalRevenues.Text = restaurantRevenueVMs.Sum(x => x.Price).ToString();
        }