Beispiel #1
0
        public static void Enqueue(Exception ex)
        {
            ErrorEventArgs m_Args = new ErrorEventArgs();

            m_Args.Exception  = ex;
            m_Args.HappenedAt = DateTime.Now;

            EventSink.InvokeError("Logger", m_Args);

            try
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Event m_Event = new Event();
                    m_Event.AuthorID    = Program.User.ID;
                    m_Event.CreatedAt   = DateTime.Now;
                    m_Event.Description = string.Format("{0} - {1}", ex.Message, ex.StackTrace);
                    m_Event.CategoryID  = 3; //Hata
                    m_Event.OwnerID     = Program.User.WorksAtID;
                    m_Context.Events.Add(m_Event);
                    m_Context.SaveChanges();
                }
            }
            catch (Exception exp)
            {
            }
        }
Beispiel #2
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.Users_List.SelectedItems.Count > 0)
            {
                if (MessageBox.Show("Seçili Kullanıcıyı silmek istediğinizden emin misiniz?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    MuhasebeEntities m_Context = new MuhasebeEntities();
                    ListViewItem     m_Select  = this.Users_List.SelectedItems[0];
                    int m_ItemID = Convert.ToInt32(m_Select.Tag);

                    if (m_Select.Tag != null && m_ItemID > 0)
                    {
                        User m_User = m_Context.Users.Where(q => q.ID == m_ItemID).FirstOrDefault();

                        if (m_User != null)
                        {
                            m_Context.Users.Remove(m_User);
                            m_Context.SaveChanges();
                            PopulateListView();
                        }
                        else
                        {
                            MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void Save_Button_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                BarcodeTemplate m_Actual = m_Context.BarcodeTemplates.Where(q => q.ID == this.Template.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.Name   = this.Name_Box.Text;
                    m_Actual.Path   = this.Path_Box.Text;
                    m_Actual.Width  = Convert.ToInt32(this.Width_Num.Value);
                    m_Actual.Height = Convert.ToInt32(this.Height_Num.Value);

                    if (this.IsDefault_Check.Checked)
                    {
                        m_Context.BarcodeTemplates.Where(q => q.OwnerID == Program.User.WorksAtID).All(delegate(BarcodeTemplate template)
                        {
                            template.IsDefault = false;
                            return(true);
                        });
                    }

                    m_Actual.IsDefault = this.IsDefault_Check.Checked;

                    m_Context.SaveChanges();
                    InvokeItemEdited(m_Actual);
                }
                else
                {
                    MessageBox.Show("Düzenlemeye çalıştığınız tasarım artık yok.", "Hata", MessageBoxButtons.OK);
                }

                this.Close();
            }
        }
Beispiel #4
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateAll())
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    this.Offer.AuthorID  = Program.User.ID;
                    this.Offer.CreatedAt = DateTime.Now;
                    this.Offer.OwnerID   = Program.User.WorksAtID.Value;
                    this.Offer.Name      = this.Name_Box.Text;
                    this.Offer.Note      = this.Attn_Note.Text;

                    if (this.Account_Box.SelectedValue != null)
                    {
                        int m_AccountID = Convert.ToInt32(this.Account_Box.SelectedValue);
                        this.Offer.AccountID = m_AccountID;
                    }

                    this.Offer.Nodes.All(delegate(OfferNode node)
                    {
                        node.Item = null;

                        return(true);
                    });

                    m_Context.Offers.Add(this.Offer);
                    m_Context.SaveChanges();

                    this.Close();
                }
            }
        }
Beispiel #5
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.BarcodeTemplates_List.SelectedItems.Count > 0)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    ListViewItem m_Item   = this.BarcodeTemplates_List.SelectedItems[0];
                    int          m_ItemID = Convert.ToInt32(m_Item.Tag);

                    if (m_Item.Tag != null && m_ItemID > 0)
                    {
                        if (MessageBox.Show("Bu tasarım kalıcı olarak silinecek, emin misiniz?", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            BarcodeTemplate m_Template = m_Context.BarcodeTemplates.Where(q => q.ID == m_ItemID).FirstOrDefault();

                            if (m_Template != null)
                            {
                                m_Context.BarcodeTemplates.Remove(m_Template);
                                m_Context.SaveChanges();
                                m_Item.Remove();
                                PopulateListView();
                            }
                            else
                            {
                                MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #6
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateAll())
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Account m_Account = new Account();
                    m_Account.AccountTypeID = Convert.ToInt32(this.AccountType_Combo.SelectedValue);
                    m_Account.Name          = this.AccountName_Box.Text;
                    m_Account.CityID        = Convert.ToInt32(this.City_Combo.SelectedValue);
                    m_Account.ProvinceID    = Convert.ToInt32(this.Province_Combo.SelectedValue);
                    m_Account.Address       = this.Address_Box.Text;
                    m_Account.Phone         = this.Phone_Box.Text;
                    m_Account.Gsm           = this.Gsm_Box.Text;
                    m_Account.Email         = this.Email_Box.Text;
                    m_Account.OwnerID       = Program.User.WorksAtID.Value;
                    m_Account.TaxDepartment = this.TaxDepartment_Box.Text;
                    m_Account.TaxID         = this.TaxID_Box.Text;

                    m_Context.Accounts.Add(m_Account);
                    m_Context.SaveChanges();

                    this.Close();
                }
            }
        }
Beispiel #7
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.Device_List.SelectedItems.Count > 0)
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                ListViewItem     m_Item    = this.Device_List.SelectedItems[0];
                int m_ItemID = Convert.ToInt32(m_Item.Tag);

                if (m_Item.Tag != null && m_ItemID > 0)
                {
                    Device m_Device = m_Context.Devices.Where(q => q.ID == m_ItemID).FirstOrDefault();

                    if (m_Device != null)
                    {
                        DeviceManager.Disconnect(m_Device.ID);
                        m_Context.Devices.Remove(m_Device);
                        m_Context.SaveChanges();
                        m_Item.Remove();
                        PopulateDeviceList();
                    }
                    else
                    {
                        MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #8
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                BarcodeTemplate m_Template = new BarcodeTemplate();
                m_Template.CreatedAt = DateTime.Now;
                m_Template.OwnerID   = Program.User.WorksAtID;
                m_Template.Name      = this.Name_Box.Text;
                m_Template.Path      = this.Path_Box.Text;
                m_Template.Width     = Convert.ToInt32(this.Width_Num.Value);
                m_Template.Height    = Convert.ToInt32(this.Height_Num.Value);

                if (this.IsDefault_Check.Checked)
                {
                    m_Context.BarcodeTemplates.Where(q => q.OwnerID == Program.User.WorksAtID).All(delegate(BarcodeTemplate template)
                    {
                        template.IsDefault = false;
                        return(true);
                    });
                }

                m_Template.IsDefault = this.IsDefault_Check.Checked;

                m_Context.BarcodeTemplates.Add(m_Template);
                m_Context.SaveChanges();

                this.Close();
            }
        }
Beispiel #9
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                User             m_User    = new User();

                m_User.Name       = this.Name_Box.Text;
                m_User.Surname    = this.Surname_Box.Text;
                m_User.Email      = this.Email_Box.Text;
                m_User.BornAt     = this.Birthday_Picker.Value;
                m_User.Password   = this.PW_Box.Text;
                m_User.PositionID = Convert.ToInt32(this.Position_Combo.SelectedValue);
                m_User.WorksAtID  = Program.User.WorksAtID;
                m_User.State      = "Active";
                m_User.Level      = "User";
                m_User.CreatedAt  = DateTime.Now;

                m_Context.Users.Add(m_User);
                m_Context.SaveChanges();

                this.InvokeUserAdded(m_User);
                this.Close();
            }
        }
Beispiel #10
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                ItemGroup m_Existing = m_Context.ItemGroups.Where(q => q.Name == this.Name_Box.Text).FirstOrDefault();

                if (m_Existing != null)
                {
                    MessageBox.Show("Aynı adla başka bir grup oluşturmuşsunuz, lütfen başka bir ad giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (this.Name_Box.Text == string.Empty || this.Name_Box.Text.Length < 3)
            {
                MessageBox.Show("Lütfen en az 3 karakterden oluşan bir ürün grubu adı giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    ItemGroup m_Group = new ItemGroup();
                    m_Group.Name = this.Name_Box.Text;
                    m_Context.ItemGroups.Add(m_Group);
                    m_Context.SaveChanges();
                }

                this.Close();
            }
        }
Beispiel #11
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateAll())
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Account m_Existing = m_Context.Accounts.Where(q => q.ID == this.Account.ID).FirstOrDefault();

                    if (m_Existing != null)
                    {
                        m_Existing.AccountTypeID = Convert.ToInt32(this.AccountType_Combo.SelectedValue);
                        m_Existing.Name          = this.AccountName_Box.Text;
                        m_Existing.CityID        = Convert.ToInt32(this.City_Combo.SelectedValue);
                        m_Existing.ProvinceID    = Convert.ToInt32(this.Province_Combo.SelectedValue);
                        m_Existing.Address       = this.Address_Box.Text;
                        m_Existing.Phone         = this.Phone_Box.Text;
                        m_Existing.Gsm           = this.Gsm_Box.Text;
                        m_Existing.Email         = this.Email_Box.Text;
                        m_Existing.TaxDepartment = this.TaxDepartment_Box.Text;
                        m_Existing.TaxID         = this.TaxID_Box.Text;

                        m_Context.SaveChanges();
                    }

                    this.Close();
                }
            }
        }
        private void Delete_Btn_Click(object sender, EventArgs e)
        {
            if (this.Inventory_List.SelectedItems.Count > 0)
            {
                ListViewItem m_Item = this.Inventory_List.SelectedItems[0];

                if (m_Item.Tag != null)
                {
                    if (MessageBox.Show("Bu depo silinecek, ürünlerin depo bilgisi -yok- olarak gözükecektir. Emin misinz?", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        using (MuhasebeEntities m_Context = new MuhasebeEntities())
                        {
                            int       m_ItemID    = Convert.ToInt32(m_Item.Tag);
                            Inventory m_Inventory = m_Context.Inventories.Where(q => q.ID == m_ItemID).FirstOrDefault();

                            m_Context.Inventories.Remove(m_Inventory);
                            m_Context.SaveChanges();
                            m_Item.Remove();
                        }

                        this.PopulateList();
                    }
                }
                else
                {
                    MessageBox.Show("Silme işlemi başarısız, bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #13
0
        private void Save_Btn_Click(object sender, EventArgs e)
        {
            if (this.Income != null)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Income m_Actual = m_Context.Incomes.Where(q => q.ID == this.Income.ID).FirstOrDefault();

                    if (m_Actual != null)
                    {
                        m_Actual.CreatedAt    = this.Revenue_Date_Picker.Value;
                        m_Actual.Amount       = this.Revenue_Amount_Num.Value;
                        m_Actual.IncomeTypeID = Convert.ToInt32(this.Revenue_Type_Combo.SelectedValue);
                        m_Actual.AuthorID     = Convert.ToInt32(this.Responsible_Combo.SelectedValue);
                        m_Actual.OwnerID      = Program.User.WorksAtID;
                        m_Actual.Description  = this.Description_Box.Text;

                        if (m_Actual.Account != null)
                        {
                            AccountMovement m_Movement = m_Context.AccountMovements.Where(q => q.MovementTypeID == 2 && q.ContractID == m_Actual.ID).FirstOrDefault();

                            if (m_Movement != null)
                            {
                                m_Movement.Value = m_Actual.Amount.Value;
                            }
                        }

                        m_Context.SaveChanges();
                        InvokeRevenueEdited(m_Actual);

                        this.Close();
                    }
                }
            }
        }
Beispiel #14
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.UnitTypes_List.SelectedItems.Count > 0)
            {
                ListViewItem m_Item = this.UnitTypes_List.SelectedItems[0];

                if (m_Item.Tag != null)
                {
                    MuhasebeEntities m_Context = new MuhasebeEntities();
                    int      m_ItemID          = Convert.ToInt32(m_Item.Tag);
                    UnitType m_Type            = m_Context.UnitTypes.Where(q => q.ID == m_ItemID).FirstOrDefault();

                    if (m_Type.OwnerID != null && m_Type.OwnerID == Program.User.WorksAtID)
                    {
                        m_Context.UnitTypes.Remove(m_Type);
                        m_Context.SaveChanges();
                        m_Item.Remove();

                        PopulateList();
                    }
                    else
                    {
                        MessageBox.Show("Bu nesneyi silmek için yetkiniz yok.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Silme işlemi başarısız, bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #15
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.User != null)
            {
                if (ValidateInput())
                {
                    MuhasebeEntities m_Context = new MuhasebeEntities();

                    User m_Actual = m_Context.Users.Where(q => q.ID == this.User.ID).FirstOrDefault();

                    if (m_Actual != null)
                    {
                        m_Actual.Email      = this.Email_Box.Text;
                        m_Actual.Password   = this.PW_Box.Text;
                        m_Actual.Name       = this.Name_Box.Text;
                        m_Actual.Surname    = this.Surname_Box.Text;
                        m_Actual.BornAt     = Convert.ToDateTime(this.Birthday_Picker.Value);
                        m_Actual.PositionID = Convert.ToInt32(this.Position_Combo.SelectedValue);

                        m_Context.SaveChanges();
                        UserInvokeEdited(m_Actual);

                        this.Close();
                    }
                }
            }
        }
Beispiel #16
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();

                Product m_Product = m_Context.Products.Where(q => q.Barcode == this.Barcode_Box.Text).FirstOrDefault();

                if (m_Product == null)
                {
                    m_Product         = new Product();
                    m_Product.Name    = this.Name_Box.Text;
                    m_Product.Barcode = this.Barcode_Box.Text;

                    m_Context.Products.Add(m_Product);
                    m_Context.SaveChanges();

                    m_Product = m_Context.Products.Where(q => q.Barcode == m_Product.Barcode).FirstOrDefault(); // refreshing
                }

                Item m_Item = new Item();
                m_Item.Amount      = this.Amount_Num.Value;
                m_Item.BasePrice   = this.Base_Price_Num.Value;
                m_Item.FinalPrice  = this.Final_Price_Num.Value;
                m_Item.TermedPrice = this.Termed_Price_Num.Value;
                m_Item.InventoryID = Convert.ToInt32(this.Inventory_Combo.SelectedValue);
                m_Item.CreatedAt   = DateTime.Now;
                m_Item.Tax         = Convert.ToInt32(this.Tax_Num.Value);
                m_Item.UnitTypeID  = Convert.ToInt32(this.Unit_Type_Combo.SelectedValue);
                m_Item.ProductID   = m_Product.ID;
                m_Item.GroupID     = Convert.ToInt32(this.Group_Combo.SelectedValue);
                m_Item.OrderCode   = this.OrderCode_Box.Text;

                m_Context.Items.Add(m_Item);
                m_Context.SaveChanges();

                if (this.Picture_Box.Image != null)
                {
                    Image m_Image = this.Picture_Box.Image;
                    m_Item.SynchronizeImage(m_Image);
                }

                InvokeItemAdded(m_Item);
                this.Close();
            }
        }
Beispiel #17
0
        private void Save_Btn_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities()) {
                Expenditure m_Expenditure = new Expenditure();

                m_Expenditure.CreatedAt         = this.CreatedAt_Picker.Value;
                m_Expenditure.ExpenditureTypeID = Convert.ToInt32(this.Expenditure_Combo.SelectedValue);
                m_Expenditure.Amount            = this.Cost_Num.Value;
                m_Expenditure.AuthorID          = Convert.ToInt32(this.Responsible_Combo.SelectedValue);
                m_Expenditure.OwnerID           = Program.User.WorksAtID;
                m_Expenditure.Description       = this.ExpenditureDesc_Text.Text;

                m_Context.Expenditures.Add(m_Expenditure);
                m_Context.SaveChanges();

                if (this.Account_Box.SelectedValue != null)
                {
                    int     m_AccountID = Convert.ToInt32(this.Account_Box.SelectedValue);
                    Account m_Account   = m_Context.Accounts.Where(q => q.ID == m_AccountID).FirstOrDefault();

                    if (m_Account != null)
                    {
                        m_Expenditure.AccountID = m_Account.ID;

                        AccountMovement m_Movement = new AccountMovement();
                        m_Movement.AccountID      = m_AccountID;
                        m_Movement.AuthorID       = Program.User.ID;
                        m_Movement.MovementTypeID = 4; // Borç ödemesi yapıldı.
                        m_Movement.OwnerID        = Program.User.WorksAtID.Value;
                        m_Movement.PaymentTypeID  = 1; //Peşin haliyle
                        m_Movement.Value          = m_Expenditure.Amount.Value;
                        m_Movement.ContractID     = m_Expenditure.ID;
                        m_Movement.CreatedAt      = this.CreatedAt_Picker.Value;

                        m_Context.AccountMovements.Add(m_Movement);
                        m_Expenditure.MovementID = m_Movement.ID;
                    }
                }

                m_Context.SaveChanges();

                InvokeExpenditureAdded(m_Expenditure);
                this.Close();
            }
        }
Beispiel #18
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateAll())
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Offer m_Actual = m_Context.Offers.Where(q => q.ID == this.Offer.ID).FirstOrDefault();

                    if (m_Actual != null)
                    {
                        m_Context.OfferNodes.RemoveRange(m_Actual.Nodes);
                        m_Actual.Nodes.Clear();

                        m_Context.SaveChanges();

                        this.Offer.Nodes.All(delegate(OfferNode node)
                        {
                            m_Actual.Nodes.Add(new OfferNode()
                            {
                                Amount = node.Amount, BasePrice = node.BasePrice, Description = node.Description, FinalPrice = node.FinalPrice, ItemID = node.ItemID
                            });

                            return(true);
                        });
                    }

                    m_Actual.AuthorID  = Program.User.ID;
                    m_Actual.CreatedAt = DateTime.Now;
                    m_Actual.OwnerID   = Program.User.WorksAtID.Value;
                    m_Actual.Name      = this.Name_Box.Text;
                    m_Actual.Note      = this.Attn_Note.Text;

                    if (this.Account_Box.SelectedValue != null)
                    {
                        int m_AccountID = Convert.ToInt32(this.Account_Box.SelectedValue);
                        m_Actual.AccountID = m_AccountID;
                    }

                    m_Context.SaveChanges();

                    this.Close();
                }
            }
        }
Beispiel #19
0
        private void PopulateListView()
        {
            this.Reminding_List.Items.Clear();

            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                var m_Items = m_Context.PropertyReminders.Where(q => q.Owner.ID == Program.User.WorksAtID).ToList();

                int   i        = 0;
                Color m_Shaded = Color.FromArgb(240, 240, 240);


                m_Items.All(delegate(PropertyReminder m_Reminder)
                {
                    if (m_Reminder.Item == null)
                    {
                        m_Context.PropertyReminders.Remove(m_Reminder);
                        m_Context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        string m_Minimum = "";
                        string m_Maximum = "";

                        m_Minimum = m_Reminder.Item.GetFormattedAmount(m_Reminder.Minimum.Value);
                        m_Maximum = m_Reminder.Item.GetFormattedAmount(m_Reminder.Maximum.Value);

                        ListViewItem m_ViewItem = new ListViewItem();
                        m_ViewItem.Text         = m_Reminder.Item.Product.Name;
                        m_ViewItem.SubItems.Add(m_Reminder.Item.Product.Barcode);
                        m_ViewItem.SubItems.Add(m_Minimum);
                        m_ViewItem.SubItems.Add(m_Maximum);
                        m_ViewItem.SubItems.Add(m_Reminder.Responsible.FullName);
                        m_ViewItem.SubItems.Add(m_Reminder.Item.UnitType.Name);
                        m_ViewItem.SubItems.Add(m_Reminder.PropertyRemindingMethod.Name);
                        m_ViewItem.Tag = m_Reminder.ID;

                        if (i++ % 2 == 1)
                        {
                            m_ViewItem.BackColor = m_Shaded;
                            m_ViewItem.UseItemStyleForSubItems = true;
                        }

                        this.Reminding_List.Items.Add(m_ViewItem);

                        return(true);
                    }
                });
            }
        }
Beispiel #20
0
        private void Save_Btn_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                Income m_Income = new Income();
                m_Income.CreatedAt    = this.Revenue_Date_Picker.Value;
                m_Income.Amount       = this.Revenue_Amount_Num.Value;
                m_Income.AuthorID     = Convert.ToInt32(this.Responsible_Combo.SelectedValue);
                m_Income.Description  = this.Description_Box.Text;
                m_Income.IncomeTypeID = Convert.ToInt32(this.Revenue_Type_Combo.SelectedValue);
                m_Income.OwnerID      = Program.User.WorksAtID;

                m_Context.Incomes.Add(m_Income);
                m_Context.SaveChanges();

                if (this.Account_Box.SelectedValue != null)
                {
                    int m_AccountID = Convert.ToInt32(this.Account_Box.SelectedValue);
                    m_Income.AccountID = m_AccountID;

                    AccountMovement m_Movement = new AccountMovement();
                    m_Movement.CreatedAt      = this.Revenue_Date_Picker.Value;
                    m_Movement.AccountID      = m_AccountID;
                    m_Movement.AuthorID       = Program.User.ID;
                    m_Movement.ContractID     = m_Income.ID;
                    m_Movement.MovementTypeID = 2; //Alacak tahsilatı
                    m_Movement.OwnerID        = Program.User.WorksAtID.Value;
                    m_Movement.PaymentTypeID  = 1; //Nakit
                    m_Movement.Value          = m_Income.Amount.Value;

                    m_Context.AccountMovements.Add(m_Movement);
                    m_Context.SaveChanges();
                }

                InvokeRevenueAdded(m_Income);
            }

            this.Close();
        }
Beispiel #21
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            PaymentType m_PaymentType = new PaymentType();

            m_PaymentType.Name    = this.Name_Box.Text;
            m_PaymentType.OwnerID = Convert.ToInt32(Program.User.WorksAtID.ToString());

            MuhasebeEntities m_Context = new MuhasebeEntities();

            m_Context.PaymentTypes.Add(m_PaymentType);
            m_Context.SaveChanges();

            InvokePaymentTypeAdded(m_PaymentType);
            this.Close();
        }
Beispiel #22
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            MuhasebeEntities m_Context   = new MuhasebeEntities();
            Inventory        m_Inventory = new Inventory();

            m_Inventory.Name        = this.Storge_Name_Box.Text;
            m_Inventory.Address     = this.Storge_Adress_Box.Text;
            m_Inventory.Description = this.Storge_Description_Box.Text;
            m_Inventory.OwnerID     = Program.User.WorksAt.ID;

            m_Context.Inventories.Add(m_Inventory);
            m_Context.SaveChanges();

            InvokeInventoryAdded(m_Inventory);
            this.Close();
        }
Beispiel #23
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.Termed_Price_Num.Value < this.Final_Price_Num.Value)
            {
                MessageBox.Show("Vadeli satış fiyatı normal satış fiyatından küçük olamaz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.Item != null)
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                Item             m_Actual  = m_Context.Items.Where(q => q.ID == this.Item.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.InventoryID  = Convert.ToInt32(this.Inventory_Combo.SelectedValue);
                    m_Actual.UnitTypeID   = Convert.ToInt32(this.Unit_Type_Combo.SelectedValue);
                    m_Actual.Amount       = this.Amount_Num.Value;
                    m_Actual.BasePrice    = this.Base_Price_Num.Value;
                    m_Actual.Tax          = Convert.ToInt32(this.Tax_Num.Value);
                    m_Actual.FinalPrice   = this.Final_Price_Num.Value;
                    m_Actual.TermedPrice  = this.Termed_Price_Num.Value;
                    m_Actual.Product.Name = this.Name_Box.Text;
                    m_Actual.GroupID      = Convert.ToInt32(this.Group_Combo.SelectedValue);
                    m_Actual.OrderCode    = this.OrderCode_Box.Text;

                    if (this.Picture_Box.ImageLocation.Length > 0 && this.Picture_Box.ImageLocation != this.Item.LocalImagePath)
                    {
                        if (File.Exists(this.Picture_Box.ImageLocation))
                        {
                            Image m_Image = Image.FromFile(this.Picture_Box.ImageLocation);
                            m_Actual.SynchronizeImage(m_Image);
                        }
                    }

                    /*else if (this.Picture_Box.Image != null)
                     * {
                     *  Image m_Image = this.Picture_Box.Image;
                     *  m_Actual.SynchronizeImage(m_Image);
                     * }*/

                    m_Context.SaveChanges();
                    InvokeItemEdited(m_Actual);

                    this.Close();
                }
            }
        }
Beispiel #24
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                UnitType m_Type = new UnitType();
                m_Type.Name          = this.Name_Box.Text;
                m_Type.Abbreviation  = this.Abbreviation_Box.Text;
                m_Type.DecimalPlaces = Convert.ToInt32(this.DecimalPlaces_Num.Value);
                m_Type.OwnerID       = Program.User.WorksAtID;

                MuhasebeEntities m_Context = new MuhasebeEntities();
                m_Context.UnitTypes.Add(m_Type);
                m_Context.SaveChanges();
                InvokeUnitTypeAdded(m_Type);

                this.Close();
            }
        }
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.PaymentType != null)
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                PaymentType      m_Actual  = m_Context.PaymentTypes.Where(q => q.ID == this.PaymentType.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.Name = this.Name_Box.Text;

                    m_Context.SaveChanges();
                    InvokePaymentTypeEdited(m_Actual);

                    this.Close();
                }
            }
        }
Beispiel #26
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();

                Company m_Company = new Company();
                m_Company.Name      = this.Comp_Name_Box.Text;
                m_Company.Sector    = this.Comp_Sector_Combo.SelectedItem.ToString();
                m_Company.Address   = this.Comp_Adress_Box.Text;
                m_Company.Province  = this.Comp_Province_Box.Text;
                m_Company.District  = this.Comp_District_Box.Text;
                m_Company.Biography = this.Comp_Biography_Box.Text;
                m_Company.Phone     = this.Phone_Box.Text;
                m_Company.Gsm       = this.CellPhone_Box.Text;
                m_Company.Fax       = this.Fax_Box.Text;
                m_Company.CreatedAt = DateTime.Now;

                User m_User = new User();
                m_User.Name       = this.Name_Box.Text;
                m_User.Surname    = this.Surname_Box.Text;
                m_User.Email      = this.Email_Box.Text;
                m_User.Password   = this.Password_Box.Text;
                m_User.BornAt     = this.BornAt_Picker.Value;
                m_User.State      = "Active";
                m_User.Level      = "User";
                m_User.PositionID = 1;
                m_User.WorksAt    = m_Company;
                m_User.CreatedAt  = DateTime.Now;

                Inventory m_Inventory = new Inventory();
                m_Inventory.Owner = m_Company;
                m_Inventory.Name  = "Depo #1";

                m_Context.Inventories.Add(m_Inventory);
                m_Context.Companies.Add(m_Company);
                m_Context.Users.Add(m_User);
                m_Context.SaveChanges();


                MessageBox.Show("Kayıt başarılı", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.Expenditure_List.SelectedItems.Count > 0)
            {
                ListViewItem m_Selected = this.Expenditure_List.SelectedItems[0];

                if (m_Selected.Tag != null)
                {
                    using (MuhasebeEntities m_Context = new MuhasebeEntities())
                    {
                        int m_ItemID = Convert.ToInt32(m_Selected.Tag);

                        Expenditure m_Expenditure = m_Context.Expenditures.Where(q => q.ID == m_ItemID).FirstOrDefault();

                        if (m_Expenditure.OwnerID != null && m_Expenditure.OwnerID == Program.User.WorksAtID)
                        {
                            if (m_Expenditure.MovementID.HasValue)
                            {
                                AccountMovement m_Movement = m_Context.AccountMovements.Where(q => q.ID == m_Expenditure.MovementID).FirstOrDefault();

                                if (m_Movement != null)
                                {
                                    m_Context.AccountMovements.Remove(m_Movement);
                                }
                            }

                            m_Context.Expenditures.Remove(m_Expenditure);
                            m_Context.SaveChanges();
                            m_Selected.Remove();

                            PopulateListView();
                        }
                        else
                        {
                            MessageBox.Show("Bu nesneyi silmek için yetkiniz bulunmamaktadır", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Silme işlemi sırasında bir hata oluştu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #28
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.UnitType != null)
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                UnitType         m_Actual  = m_Context.UnitTypes.Where(q => q.ID == this.UnitType.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.Name          = this.Name_Box.Text;
                    m_Actual.Abbreviation  = this.Abbreviation_Box.Text;
                    m_Actual.DecimalPlaces = Convert.ToInt32(this.DecimalPlaces_Num.Value);

                    m_Context.SaveChanges();
                    InvokeUnitTypeEdited(m_Actual);

                    this.Close();
                }
            }
        }
Beispiel #29
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (Inventory != null)
            {
                MuhasebeEntities m_Context = new MuhasebeEntities();
                Inventory        m_Actual  = m_Context.Inventories.Where(q => q.ID == this.Inventory.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.Name        = this.Storge_Name_Box.Text;
                    m_Actual.Address     = this.Storge_Adress_Box.Text;
                    m_Actual.Description = this.Storge_Description_Box.Text;

                    m_Context.SaveChanges();
                    InvokeInventoryEdited(m_Actual);

                    this.Close();
                }
            }
        }
Beispiel #30
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.ItemGroup != null)
            {
                if (this.Name_Box.Text == string.Empty || this.Name_Box.Text.Length < 3)
                {
                    MessageBox.Show("Lütfen en az 3 karakterden oluşan bir ürün grubu adı giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    using (MuhasebeEntities m_Context = new MuhasebeEntities())
                    {
                        ItemGroup m_Actual = m_Context.ItemGroups.Where(q => q.ID == this.ItemGroup.ID).FirstOrDefault();
                        m_Actual.Name = this.Name_Box.Text;
                        m_Context.SaveChanges();

                        InvokeItemGroupEdited(m_Actual);
                    }

                    this.Close();
                }
            }
        }