Ejemplo n.º 1
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            UnitofWork unitofWork = new UnitofWork(ctx);
            Expense_Suppliers_Service expense_Suppliers_Service = new Expense_Suppliers_Service(unitofWork);
            List <Expense_Suppliers>  expense_Suppliers         = expense_Suppliers_Service.GetAllExpense_Suppliers();

            dataGridView1.DataSource = expense_Suppliers;

            dataGridView1.Columns[0].HeaderText = "Tarih";
            dataGridView1.Columns[1].HeaderText = "Firma";
            dataGridView1.Columns[2].HeaderText = "Açıklama";
            dataGridView1.Columns[3].HeaderText = "Tutar";

            dataGridView1.Columns[4].Visible = false;
            dataGridView1.Columns[5].Visible = false;
            dataGridView1.Columns[6].Visible = false;
            dataGridView1.Columns[7].Visible = false;
            dataGridView1.Columns[8].Visible = false;

            Tools tools = new Tools();

            tools.DataGridViewResize(dataGridView1, 4);

            txtTotalRevenues.Text = expense_Suppliers.Sum(x => x.Price).ToString();
        }
Ejemplo n.º 2
0
        private void btnFillter_Click(object sender, EventArgs e)
        {
            DateTime DateStart  = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", dtpDateStart.Value));
            DateTime DateFinish = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", dtpDateFinish.Value));

            UnitofWork unitofWork = new UnitofWork(ctx);
            Expense_Suppliers_Service expense_Suppliers_Service = new Expense_Suppliers_Service(unitofWork);
            List <Expense_Suppliers>  expense_Suppliers         = expense_Suppliers_Service.GetAllExpense_Suppliers().Where(x => x.ExpenseDate >= DateStart && x.ExpenseDate <= DateFinish).ToList();

            dataGridView1.DataSource = expense_Suppliers;

            dataGridView1.Columns[0].HeaderText = "Tarih";
            dataGridView1.Columns[1].HeaderText = "Firma";
            dataGridView1.Columns[2].HeaderText = "Açıklama";
            dataGridView1.Columns[3].HeaderText = "Tutar";

            dataGridView1.Columns[4].Visible = false;
            dataGridView1.Columns[5].Visible = false;
            dataGridView1.Columns[6].Visible = false;
            dataGridView1.Columns[7].Visible = false;
            dataGridView1.Columns[8].Visible = false;

            Tools tools = new Tools();

            tools.DataGridViewResize(dataGridView1, 4);

            txtTotalRevenues.Text = expense_Suppliers.Sum(x => x.Price).ToString();
        }
Ejemplo n.º 3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (DailyCastingEntryType == 1)
            {
                #region Variables
                DateTime ExpenseDate  = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                decimal  Price        = nudPrice.Value;
                string   Descriptions = txtDesciptions.Text;
                #endregion

                #region Service
                UnitofWork unitofWork = new UnitofWork(ctx);
                Expense_Vehicle_Service expense_Vehicle_Service = new Expense_Vehicle_Service(unitofWork);
                TotalExpenses_Service   totalExpenses_Service   = new TotalExpenses_Service(unitofWork);
                #endregion

                if (Price > 0 && !string.IsNullOrEmpty(Descriptions))
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Expense_Vehicle expense_Vehicle = new Expense_Vehicle()
                        {
                            ExpenseDate  = ExpenseDate,
                            Descriptions = Descriptions,
                            Price        = Price
                        };
                        if (expense_Vehicle_Service.Insert(expense_Vehicle))
                        {
                            TotalExpenses totalExpenses = totalExpenses_Service.GetTotalExpenses(ExpenseDate, ExpenseType.Vehicle);
                            if (totalExpenses != null)
                            {
                                totalExpenses.Price += Price;
                                if (totalExpenses_Service.Update(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    txtDesciptions.Text = "";
                                    nudPrice.Value      = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                totalExpenses = new TotalExpenses()
                                {
                                    ExpenseDate            = ExpenseDate,
                                    ExpenseType            = ExpenseType.Vehicle,
                                    ExpenseTypeDesciptions = "Araç",
                                    Price  = Price,
                                    Status = Status.Active,
                                };
                                if (totalExpenses_Service.Insert(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    txtDesciptions.Text = "";
                                    nudPrice.Value      = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        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 == 2)
            {
                #region Variables
                DateTime    ExpenseDate = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                InvoiceType invoiceType = new InvoiceType();
                switch (cmbInvoice.SelectedValue)
                {
                case "0":
                    invoiceType = InvoiceType.That; break;

                case "1":
                    invoiceType = InvoiceType.Electricity; break;

                case "2":
                    invoiceType = InvoiceType.NaturalGas; break;

                case "3":
                    invoiceType = InvoiceType.Internet; break;

                case "4":
                    invoiceType = InvoiceType.Other; break;

                default:
                    break;
                }
                string  Descriptions = txtDesciptions.Text;
                decimal Price        = nudPrice.Value;
                #endregion

                #region Service
                UnitofWork unitofWork = new UnitofWork(ctx);
                Expense_Invoice_Service expense_Invoice_Service = new Expense_Invoice_Service(unitofWork);
                TotalExpenses_Service   totalExpenses_Service   = new TotalExpenses_Service(unitofWork);
                #endregion

                if (Price > 0 && cmbInvoice.Text != "Fatura Tipi Seçiniz...")
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Expense_Invoice expense_Invoice = new Expense_Invoice()
                        {
                            ExpenseDate  = ExpenseDate,
                            InvoiceType  = enumHelper.GetEnumDescription(invoiceType),
                            Descriptions = Descriptions,
                            Price        = Price,
                            Status       = Status.Active
                        };
                        if (expense_Invoice_Service.Insert(expense_Invoice))
                        {
                            TotalExpenses totalExpenses = totalExpenses_Service.GetTotalExpenses(ExpenseDate, ExpenseType.Invoice);
                            if (totalExpenses != null)
                            {
                                totalExpenses.Price += Price;
                                if (totalExpenses_Service.Update(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbInvoice.SelectedIndex = 0;
                                    txtDesciptions.Text      = "";
                                    nudPrice.Value           = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                totalExpenses = new TotalExpenses()
                                {
                                    ExpenseDate            = ExpenseDate,
                                    ExpenseType            = ExpenseType.Invoice,
                                    ExpenseTypeDesciptions = "Fatura",
                                    Price  = Price,
                                    Status = Status.Active,
                                };
                                if (totalExpenses_Service.Insert(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbInvoice.SelectedIndex = 0;
                                    txtDesciptions.Text      = "";
                                    nudPrice.Value           = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        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
                DateTime ExpenseDate  = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                string   SupplirsCode = cmbSuppliers.SelectedValue.ToString();
                decimal  Price        = nudPrice.Value;
                string   Descriptions = txtDesciptions.Text;
                #endregion

                #region Service
                UnitofWork unitofWork = new UnitofWork(ctx);
                SupplierCompanies_Service supplierCompanies_Service = new SupplierCompanies_Service(unitofWork);
                Expense_Suppliers_Service expense_Suppliers_Service = new Expense_Suppliers_Service(unitofWork);
                TotalExpenses_Service     totalExpenses_Service     = new TotalExpenses_Service(unitofWork);
                #endregion

                if (!string.IsNullOrEmpty(SupplirsCode) && Price > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        SupplierCompanies supplierCompanies = supplierCompanies_Service.GetSupplierCompanies(SupplirsCode);
                        Expense_Suppliers expense_Suppliers = new Expense_Suppliers()
                        {
                            Status       = Status.Active,
                            ExpenseDate  = ExpenseDate,
                            Price        = Price,
                            Descriptions = Descriptions,
                            SupplierCode = supplierCompanies.Code,
                            SupplierName = supplierCompanies.Name
                        };
                        if (expense_Suppliers_Service.Insert(expense_Suppliers))
                        {
                            TotalExpenses totalExpenses = totalExpenses_Service.GetTotalExpenses(ExpenseDate, ExpenseType.Suppliers);
                            if (totalExpenses != null)
                            {
                                totalExpenses.Price += Price;
                                if (totalExpenses_Service.Update(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbSuppliers.SelectedIndex = 0;
                                    txtDesciptions.Text        = "";
                                    nudPrice.Value             = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                totalExpenses = new TotalExpenses()
                                {
                                    ExpenseDate            = ExpenseDate,
                                    ExpenseType            = ExpenseType.Suppliers,
                                    ExpenseTypeDesciptions = "Tedarikçi",
                                    Price  = Price,
                                    Status = Status.Active,
                                };
                                if (totalExpenses_Service.Insert(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbSuppliers.SelectedIndex = 0;
                                    txtDesciptions.Text        = "";
                                    nudPrice.Value             = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        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 == 4)
            {
                #region Variables
                DateTime ExpenseDate      = Convert.ToDateTime(string.Format("{0: dd/MM/yyyy 00:00:00}", DateTime.Now));
                string   FullName         = cmbStaffs.Text;
                string   StaffExpenseType = cmbStaffExpense.Text;
                decimal  Price            = nudPrice.Value;
                #endregion

                #region Service
                UnitofWork            unitofWork            = new UnitofWork(ctx);
                Staff_Service         staff_Service         = new Staff_Service(unitofWork);
                Expense_Staff_Service expense_Staff_Service = new Expense_Staff_Service(unitofWork);
                TotalExpenses_Service totalExpenses_Service = new TotalExpenses_Service(unitofWork);
                #endregion

                if (!string.IsNullOrEmpty(FullName) && !string.IsNullOrEmpty(StaffExpenseType) && Price > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Kaydı Eklemek İstediğinize Emin misiniz?", "Yeni Kayıt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Expense_Staff expense_Staff = new Expense_Staff()
                        {
                            ExpenseDate      = ExpenseDate,
                            FullName         = FullName,
                            Price            = Price,
                            StaffExpenseType = StaffExpenseType,
                            Status           = Status.Active
                        };
                        if (expense_Staff_Service.Insert(expense_Staff))
                        {
                            TotalExpenses totalExpenses = totalExpenses_Service.GetTotalExpenses(ExpenseDate, ExpenseType.Staff);
                            if (totalExpenses != null)
                            {
                                totalExpenses.Price += Price;
                                if (totalExpenses_Service.Update(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbStaffs.SelectedIndex       = 0;
                                    cmbStaffExpense.SelectedIndex = 0;
                                    nudPrice.Value = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                totalExpenses = new TotalExpenses()
                                {
                                    ExpenseDate            = ExpenseDate,
                                    ExpenseType            = ExpenseType.Staff,
                                    ExpenseTypeDesciptions = "Personel",
                                    Price  = Price,
                                    Status = Status.Active,
                                };
                                if (totalExpenses_Service.Insert(totalExpenses))
                                {
                                    MessageBox.Show("İşlem Başarılı.");

                                    cmbStaffs.SelectedIndex       = 0;
                                    cmbStaffExpense.SelectedIndex = 0;
                                    nudPrice.Value = 0;
                                }
                                else
                                {
                                    MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("İşlem Başarısız.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Boş Geçilemez.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }