コード例 #1
0
        private void Group_Combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            int m_GroupID = Convert.ToInt32(this.Group_Combo.SelectedValue);

            if (m_GroupID > 0)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    var m_TotalItems = m_Context.ItemGroups.Where(q => q.ID == m_GroupID).FirstOrDefault().Items.Count;
                    this.Distinct_Label.Text = string.Format("{0} kalem ürün etkilenecek", m_TotalItems);

                    SelectExampleItem();
                }
            }
        }
コード例 #2
0
        private void OrderNode_Edit_Gumpling_Load(object sender, EventArgs e)
        {
            if (this.OrderNode != null)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    Item m_Item = m_Context.Items.Where(q => q.ID == this.OrderNode.ItemID).FirstOrDefault();

                    if (m_Item != null)
                    {
                        this.Unit_Label.Text          = m_Item.UnitType.Name;
                        this.Amount_Num.DecimalPlaces = m_Item.UnitType.DecimalPlaces;

                        this.Amount_Num.Value     = this.OrderNode.Amount;
                        this.Description_Box.Text = this.OrderNode.Description;
                    }
                }
            }
        }
コード例 #3
0
        private void SelectExampleItem()
        {
            int m_GroupID = Convert.ToInt32(this.Group_Combo.SelectedValue);

            if (m_GroupID > 0)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    int m_Skip = new Random().Next(0, m_Context.ItemGroups.Where(q => q.ID == m_GroupID).FirstOrDefault().Items.Count - 1);

                    Item m_Item = m_Context.Items.Where(q => q.GroupID == m_GroupID).OrderByDescending(q => q.ID).Skip(m_Skip).Take(1).FirstOrDefault();

                    if (m_Item != null)
                    {
                        this.Example = m_Item;
                        UpdateExample();
                    }
                }
            }
        }
コード例 #4
0
ファイル: SearchBox.cs プロジェクト: webesen/Muhasebe
        private List <SearchEntity> SuggestStrings(string needle)
        {
            if (Program.User == null)
            {
                return(null);
            }

            List <SearchEntity> result = null;

            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                switch (this.FillType)
                {
                case Fillable.Account:
                {
                    result = m_Context.Accounts.Where(q => q.Name.Contains(needle)).Select(q => new SearchEntity {
                            ID = q.ID, Name = q.Name
                        }).ToList();

                    break;
                }

                case Fillable.Item:
                {
                    break;
                }

                case Fillable.User:
                {
                    break;
                }

                case Fillable.Barcode:
                {
                    break;
                }
                }
            }

            return(result);
        }
コード例 #5
0
        private void Change_Prices_Gumpling_Load(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                var m_Groups = m_Context.ItemGroups.Select(q => new { ID = q.ID, Name = q.Name }).ToList();

                this.Group_Combo.DataSource    = m_Groups;
                this.Group_Combo.ValueMember   = "ID";
                this.Group_Combo.DisplayMember = "Name";

                this.Group_Combo.Invalidate();
            }

            this.Group_Combo.SelectedIndexChanged += Group_Combo_SelectedIndexChanged;
            this.Group_Combo_SelectedIndexChanged(sender, e);

            if (this.PreferredGroupID > 0)
            {
                this.Group_Combo.SelectedValue = this.PreferredGroupID;
            }

            this.radioButton3.Checked = true;
        }
コード例 #6
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            if (this.Change_Num.Value != 0 && this.Example != null)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    int m_GroupID = Convert.ToInt32(this.Group_Combo.SelectedValue);

                    ItemGroup m_Group = m_Context.ItemGroups.Where(q => q.ID == m_GroupID).FirstOrDefault();

                    if (m_Group != null)
                    {
                        decimal change = 1 + (this.Change_Num.Value / 100.00m);

                        if (this.AffectState != "Final")
                        {
                            m_Context.Items.Where(q => q.GroupID == m_GroupID).Update(q => new Item()
                            {
                                BasePrice = q.BasePrice * change
                            });
                        }

                        if (this.AffectState != "Base")
                        {
                            m_Context.Items.Where(q => q.GroupID == m_GroupID).Update(q => new Item()
                            {
                                FinalPrice = q.FinalPrice * change, TermedPrice = q.TermedPrice * change
                            });
                        }

                        m_Context.SaveChanges();
                    }
                }
            }

            this.Close();
        }
コード例 #7
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            this.Save_Button.Enabled = false;

            this.Invoke((MethodInvoker) delegate()
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    this.Account = m_Context.Accounts.Where(q => q.ID == this.Account.ID).FirstOrDefault();

                    DateTime m_BeginsAt = DateTime.MinValue;
                    DateTime m_EndsAt   = DateTime.MaxValue;

                    string m_IntervalExp = "";

                    if (this.Last_Month_Radio.Checked)
                    {
                        m_EndsAt      = DateTime.Now;
                        m_BeginsAt    = m_EndsAt.Subtract(TimeSpan.FromDays(30));
                        m_IntervalExp = string.Format("Son 1 Ay: {0} - {1}", m_BeginsAt.ToShortDateString(), m_EndsAt.ToShortDateString());
                    }
                    else if (this.Last_6Months_Radio.Checked)
                    {
                        m_EndsAt      = DateTime.Now;
                        m_BeginsAt    = m_EndsAt.Subtract(TimeSpan.FromDays(180));
                        m_IntervalExp = string.Format("Son 6 Ay: {0} - {1}", m_BeginsAt.ToShortDateString(), m_EndsAt.ToShortDateString());
                    }
                    else if (this.Last_2Years_Radio.Checked)
                    {
                        m_EndsAt      = DateTime.Now;
                        m_BeginsAt    = m_EndsAt.Subtract(TimeSpan.FromDays(365 * 2));
                        m_IntervalExp = string.Format("Son 24 Ay: {0} - {1}", m_BeginsAt.ToShortDateString(), m_EndsAt.ToShortDateString());
                    }
                    else if (this.Specific_Radio.Checked)
                    {
                        m_EndsAt      = EndsAt_Picker.Value;
                        m_BeginsAt    = BeginsAt_Picker.Value;
                        m_IntervalExp = string.Format("Belirli Tarih Aralığı: {0} - {1}", m_BeginsAt.ToString(), m_EndsAt.ToString());
                    }

                    List <AccountMovement> m_List = m_Context.AccountMovements.Where(q => q.AccountID == this.Account.ID && (q.CreatedAt >= m_BeginsAt && q.CreatedAt <= m_EndsAt)).ToList();
                    m_List = m_List.OrderBy(q => q.CreatedAt).ToList();

                    string m_Data            = "";
                    string m_SummaryTemplate = "Yukarıdaki işlemler sonucunda firmamız <strong>{0}</strong>";
                    string m_BaseTemplate    = "<tr class=\"movement\">" +
                                               "<td class=\"id\">{0}</td>" +
                                               "<td class=\"mtype\">{1}</td>" +
                                               "<td class=\"date\">{2}</td>" +
                                               "<td class=\"author\">{3}</td>" +
                                               "<td class=\"payment\">{4}</td>" +
                                               "<td class=\"desc\">{5}</td> " +
                                               "<td class=\"price\">{6}</td>" +
                                               "</tr>";

                    m_List.All(delegate(AccountMovement movement)
                    {
                        string m_Description = "";

                        if (movement.MovementTypeID != 3)                                    // ürün tedariğinde yorum yok
                        {
                            if (movement.MovementTypeID == 1 && movement.PaymentTypeID != 3) // Vadeli satış değilse
                            {
                                Income m_Income = m_Context.Incomes.Where(q => q.InvoiceID == movement.ContractID).FirstOrDefault();

                                if (m_Income != null)
                                {
                                    m_Description = m_Income.Description;
                                }
                            }
                            else if (movement.MovementTypeID == 2) // Alacak tahsilatı, gelir
                            {
                                Income m_Income = m_Context.Incomes.Where(q => q.ID == movement.ContractID).FirstOrDefault();

                                if (m_Income != null)
                                {
                                    m_Description = m_Income.Description;
                                }
                            }
                            else if (movement.MovementTypeID == 4) // Borç ödemesi, gider
                            {
                                Expenditure m_Expenditure = m_Context.Expenditures.Where(q => q.ID == movement.ContractID).FirstOrDefault();

                                if (m_Expenditure != null)
                                {
                                    m_Description = m_Expenditure.Description;
                                }
                            }
                        }

                        string m_Formatted = string.Format(m_BaseTemplate, movement.ID, movement.MovementType.Name, movement.CreatedAt.ToString("dd/MM/yyyy"),
                                                           movement.Author.FullName, movement.PaymentType.Name, m_Description, ItemHelper.GetFormattedPrice(movement.Value));

                        m_Data += m_Formatted;

                        return(true);
                    });

                    AccountSummary m_Summary = this.Account.GetSummary(m_Context.AccountMovements.Where(q => q.AccountID == this.Account.ID).ToList());

                    if (m_Summary.Net < 0)
                    {
                        m_SummaryTemplate = string.Format(m_SummaryTemplate, string.Format("sizden {0} alacaklıdır.", ItemHelper.GetFormattedPrice(Math.Abs(m_Summary.Net))));
                    }
                    else if (m_Summary.Net > 0)
                    {
                        m_SummaryTemplate = string.Format(m_SummaryTemplate, string.Format("size {0} borçludur.", ItemHelper.GetFormattedPrice(Math.Abs(m_Summary.Net))));
                    }
                    else
                    {
                        m_SummaryTemplate = "Herhangi bir alacak/borç bulunmamaktadır.";
                    }

                    this.Save_Dialog.FileName = string.Format("{0} - Hesap Özeti.pdf", this.Account.Name);

                    if (this.Save_Dialog.ShowDialog() == DialogResult.OK)
                    {
                        string m_SavePath  = this.Save_Dialog.FileName;
                        string html        = "";
                        string m_LocalPath = Application.StartupPath;
                        string m_IndexPath = Path.Combine(m_LocalPath, "View\\AccountSummaryForm\\index.html");
                        string m_AbsPath   = Path.Combine(m_LocalPath, "View\\AccountSummaryForm\\");

                        using (StreamReader m_Reader = new StreamReader(m_IndexPath, Encoding.UTF8, true))
                        {
                            html = m_Reader.ReadToEnd();
                        }

                        html = html.Replace("{PATH}", m_AbsPath);
                        html = html.Replace("{BASEPATH}", m_LocalPath);
                        html = html.Replace("{COMPANY-NAME}", Program.User.WorksAt.Name);
                        html = html.Replace("{TAXID}", Program.User.WorksAt.TaxID);
                        html = html.Replace("{TAXPLACE}", Program.User.WorksAt.TaxDepartment);
                        html = html.Replace("{ADDRESS}", Program.User.WorksAt.Address);
                        html = html.Replace("{DISTRICT}", Program.User.WorksAt.District);
                        html = html.Replace("{PROVINCE}", Program.User.WorksAt.Province);
                        html = html.Replace("{TELEPHONE}", Program.User.WorksAt.Phone);
                        html = html.Replace("{EMAIL}", Program.User.WorksAt.Email);

                        html = html.Replace("{DATA}", m_Data);
                        html = html.Replace("{SUMMARY}", m_SummaryTemplate);

                        html = html.Replace("{ACCOUNT-NAME}", this.Account.Name);
                        html = html.Replace("{ACCOUNT-TAXOFFICE}", this.Account.TaxDepartment);
                        html = html.Replace("{ACCOUNT-TAXID}", this.Account.TaxID);
                        html = html.Replace("{ACCOUNT-ADDRESS}", this.Account.Address);
                        html = html.Replace("{ACCOUNT-CITY}", this.Account.City.Name);
                        html = html.Replace("{ACCOUNT-PROVINCE}", this.Account.Province.Name);
                        html = html.Replace("{ACCOUNT-PHONE}", this.Account.Phone);
                        html = html.Replace("{ACCOUNT-GSM}", this.Account.Gsm);
                        html = html.Replace("{ACCOUNT-EMAIL}", this.Account.Email);

                        html = html.Replace("{SELL-VOLUME}", ItemHelper.GetFormattedPrice(m_Summary.SellVolume));
                        html = html.Replace("{BUY-VOLUME}", ItemHelper.GetFormattedPrice(m_Summary.BuyVolume));
                        html = html.Replace("{TOTAL-LOAN}", ItemHelper.GetFormattedPrice(m_Summary.LoanTotal));
                        html = html.Replace("{TOTAL-DEBT}", ItemHelper.GetFormattedPrice(m_Summary.DebtTotal));
                        html = html.Replace("{CHARGED}", ItemHelper.GetFormattedPrice(m_Summary.Charged));
                        html = html.Replace("{PAID}", ItemHelper.GetFormattedPrice(m_Summary.Paid));
                        html = html.Replace("{NET-LOAN}", ItemHelper.GetFormattedPrice(m_Summary.LoanNet));
                        html = html.Replace("{NET-DEBT}", ItemHelper.GetFormattedPrice(m_Summary.DebtNet));

                        html = html.Replace("{TIME-INTERVAL}", m_IntervalExp);

                        try
                        {
                            var pdf = Pdf
                                      .From(html)
                                      .OfSize(PaperSize.A4)
                                      .WithTitle("Title")
                                      .WithMargins(0.8.Centimeters())
                                      .WithoutOutline()
                                      .Portrait()
                                      .Comressed()
                                      .Content();

                            FileStream m_Stream = new FileStream(m_SavePath, FileMode.Create);

                            using (BinaryWriter m_Writer = new BinaryWriter(m_Stream))
                            {
                                m_Writer.Write(pdf, 0, pdf.Length);
                            }

                            m_Stream.Close();
                            m_Stream.Dispose();
                            MessageBox.Show("Pdf dosyası oluşturuldu.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            Logger.Enqueue(ex);
                            MessageBox.Show("Oluşan bir hata nedeniyle pdf dosyası yazılamadı. Lütfen tekrar deneyin.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            });

            this.Save_Button.Enabled = true;
            this.Close();
        }