Esempio n. 1
0
 private void SendText(long chatId, List <string> list, TypePayments typePayments, int offset, bool hasMore)
 {
     Task.Factory.StartNew(async() =>
     {
         for (int i = 0; i < list.Count; i++)
         {
             string item = list[i];
             InlineKeyboardMarkup CollectionKeyboard = new InlineKeyboardMarkup();
             string moreData = "More:" + typePayments + ":" + (offset + 15);
             if (hasMore && i + 1 == list.Count)
             {
                 CollectionKeyboard.InlineKeyboard = new InlineKeyboardCallbackButton[][] {
                     new InlineKeyboardCallbackButton[] { new InlineKeyboardCallbackButton(Settings.First(x => x.Key == "More").Value, moreData) }
                 };
                 await Bot.SendTextMessageAsync(chatId, item, ParseMode.Html, false, false, 0, CollectionKeyboard);
             }
             else
             {
                 await Bot.SendTextMessageAsync(chatId, item, ParseMode.Html, false, false, 0);
             }
             await Task.Delay(200);
         }
     });
 }
Esempio n. 2
0
        /// <summary>
        /// گردش حساب شعب
        /// </summary>
        private List <string> GetBranchesPayments(long chatId, TypePayments typePayments, int?id, out int?branchId, int offset, out bool hasMore)
        {
            List <BranchesPayments> branchesPayments;
            List <string>           textList = new List <string>();
            int    count;
            string branch = "";

            using (var db = new KiaGalleryContext())
            {
                if (id == 19)
                {
                    branchId = db.BranchesPaymentsMessage.OrderByDescending(x => x.Id).FirstOrDefault(x => x.ChatId == chatId).BranchId.GetValueOrDefault();
                    id       = branchId;
                }
                else
                {
                    branchId = id;
                }
                branch = db.Branch.Single(x => x.Id == id).Name;
                var query = db.BranchesPayments.Where(x => x.BranchId == id && x.TypePayments == typePayments).OrderByDescending(x => x.Id).Skip(offset);
                count            = query.Count();
                branchesPayments = query.Take(15).ToList();
            }
            if (Offset + 15 >= count)
            {
                hasMore = false;
            }
            else
            {
                hasMore = true;
            }
            int    index = 0;
            string date;
            string text, floatString = "", details = "";
            long   totalAmount      = 0;
            double totalGoldWage    = 0;
            float  totalGoldWeights = 0;
            double goldWeights;

            switch (typePayments)
            {
            case TypePayments.Deposits:
                branchesPayments.ForEach(x => {
                    date = DateUtility.GetPersianDate(x.CreateDate);
                    text = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    double GoldWeights = Math.Round((x.GoldAmount.GetValueOrDefault() * 4.3318) / x.GoldFee.GetValueOrDefault(), 2);
                    text += "💵💵💵" + "\n";
                    if (GoldWeights.ToString().Split('.').Count() == 1)
                    {
                        floatString = ".00";
                    }
                    text += "مبلغ واریزی " + Core.ToSeparator(x.Deposits.GetValueOrDefault()) + " ریال " + "\n";
                    text += "مبلغ " + Core.ToSeparator(x.GoldAmount.GetValueOrDefault()) + " ریال با مظنه ی " + Core.ToSeparator(x.GoldFee.GetValueOrDefault()) + " ریال ";
                    text += "به " + GoldWeights + floatString + " گرم طلا تبدیل شد." + "\n";
                    text += "مبلغ " + Core.ToSeparator(x.GoldWage.GetValueOrDefault()) + " ریال " + "از اجرت کسر شد.";
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.DifferentGoldReturns:
                branchesPayments.ForEach(x =>
                {
                    date        = DateUtility.GetPersianDate(x.CreateDate);
                    text        = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text       += "🌕↩️" + "\n";
                    goldWeights = Math.Round((x.GoldWeights.GetValueOrDefault() * x.GoldCarat.GetValueOrDefault()) / 750, 2);
                    if (goldWeights.ToString().Split('.').Count() == 1)
                    {
                        floatString = ".00";
                    }
                    text += "وزن " + x.GoldWeights + " گرم طلای متفرقه عیار " + Core.ToSeparator(x.GoldCarat.GetValueOrDefault()) + " به " + goldWeights + floatString + " گرم طلای عیار 750 تبدیل شد و از حساب طلایی کسر شد. ";
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.DifferentGoldSale:
                branchesPayments.ForEach(x =>
                {
                    date        = DateUtility.GetPersianDate(x.CreateDate);
                    text        = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text       += "🌕⬆️" + "\n";
                    goldWeights = Math.Round((x.GoldWeights.GetValueOrDefault() * x.GoldCarat.GetValueOrDefault()) / 750, 2);
                    if (goldWeights.ToString().Split('.').Count() == 1)
                    {
                        floatString = ".00";
                    }
                    text += "وزن " + x.GoldWeights + " گرم طلای متفرقه عیار " + Core.ToSeparator(x.GoldCarat.GetValueOrDefault()) + " به " + goldWeights + floatString + " گرم طلای عیار 750 تبدیل شد و به حساب طلایی اضافه شد. ";
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.DifferentReturns:
                index = 0;
                branchesPayments.ForEach(x =>
                {
                    date        = DateUtility.GetPersianDate(x.CreateDate);
                    text        = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text       += "🎁↩️" + "\n";
                    long amount = 0;
                    x.BranchesPaymentsDetails.ForEach(y => {
                        index   += 1;
                        details += index + " - ";
                        if (y.Number != null && y.Number != 0)
                        {
                            details += "تعداد " + y.Number + " عدد ";
                            amount  += y.Amount.GetValueOrDefault() * y.Number.GetValueOrDefault();
                        }
                        else
                        {
                            amount += y.Amount.GetValueOrDefault();
                        }
                        details += y.Title + " به ارزش " + Core.ToSeparator(y.Amount.GetValueOrDefault()) + " ریال" + "\n";
                    });
                    text += Core.ToSeparator(amount) + "ریال از حساب اجرت کسر شد.";
                    text += "\n" + "توضیحات:" + "\n" + details;
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.DifferentSale:
                branchesPayments.ForEach(x =>
                {
                    date        = DateUtility.GetPersianDate(x.CreateDate);
                    text        = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text       += "🎁⬆️" + "\n";
                    long Amount = 0;
                    x.BranchesPaymentsDetails.ForEach(y => {
                        index   += 1;
                        details += index + " - ";
                        if (y.Number != null && y.Number != 0)
                        {
                            details += "تعداد " + x.Number + " عدد";
                            Amount  += y.Amount.GetValueOrDefault() * y.Number.GetValueOrDefault();
                        }
                        else
                        {
                            Amount += y.Amount.GetValueOrDefault();
                        }
                        details += y.Title + " به ارزش " + Core.ToSeparator(y.Amount.GetValueOrDefault()) + " ریال" + "\n";
                    });
                    text += Core.ToSeparator(Amount) + "ریال به حساب اجرت اضافه شد.";
                    text += "\n" + "توضیحات:" + "\n" + details;
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.Returned:
                branchesPayments.ForEach(x =>
                {
                    date            = DateUtility.GetPersianDate(x.CreateDate);
                    text            = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text           += "↩️↩️↩️" + "\n";
                    double goldWage = 0;
                    index           = 0;
                    x.BranchesPaymentsDetails.ForEach(y => {
                        index            += 1;
                        goldWage          = y.GoldWeights.GetValueOrDefault() * y.GoldWage.GetValueOrDefault();
                        totalGoldWage    += goldWage;
                        totalAmount      += y.Amount.GetValueOrDefault();
                        totalGoldWeights += y.GoldWeights.GetValueOrDefault();
                        details          += index + " - " + y.Title + " به وزن " + y.GoldWeights + "گرم با اجرت " + Core.ToSeparator(goldWage) + " ریال " + "(" + " اجرت واحد " + Core.ToSeparator(y.GoldWage.GetValueOrDefault()) + " ریال " + ") " + " و سنگ و چرم " + Core.ToSeparator(y.Amount.GetValueOrDefault()) + " ریال - " + " کدشخصی:  " + y.Code + "\n";
                    });
                    if (totalGoldWeights.ToString().Split('.').Count() == 1)
                    {
                        floatString = ".00";
                    }
                    text += "مجموع " + Math.Round(totalGoldWeights, 2) + floatString + " گرم طلا با اجرت " + Core.ToSeparator(totalGoldWage) + " ریال و " + Core.ToSeparator(totalAmount) + "ریال سنگ و چرم";
                    text += " از حساب کسر شد. ";
                    text += "\n" + "توضیحات:" + "\n" + details;
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;

            case TypePayments.Sale:
                branchesPayments.ForEach(x =>
                {
                    date            = DateUtility.GetPersianDate(x.CreateDate);
                    text            = date + "🗓" + "  kia-" + x.Id.ToString() + "\n" + branch + " - " + Enums.GetTitle(x.TypePayments) + "\n";
                    text           += "⬆️⬆️⬆️" + "\n";
                    double GoldWage = 0;
                    index           = 0;
                    x.BranchesPaymentsDetails.ForEach(y => {
                        index            += 1;
                        GoldWage          = y.GoldWeights.GetValueOrDefault() * y.GoldWage.GetValueOrDefault();
                        totalGoldWage    += GoldWage;
                        totalAmount      += y.Amount.GetValueOrDefault();
                        totalGoldWeights += y.GoldWeights.GetValueOrDefault();
                        details          += index + " - " + y.Title + " به وزن " + y.GoldWeights + "گرم با اجرت " + Core.ToSeparator(GoldWage) + " ریال " + "(" + " اجرت واحد " + Core.ToSeparator(y.GoldWage.GetValueOrDefault()) + " ریال " + ") " + " و سنگ و چرم " + Core.ToSeparator(y.Amount.GetValueOrDefault()) + " ریال - " + " کدشخصی:  " + y.Code + "\n";
                    });
                    if (totalGoldWeights.ToString().Split('.').Count() == 1)
                    {
                        floatString = ".00";
                    }
                    text += "مجموع " + Math.Round(totalGoldWeights, 2) + floatString + " گرم طلا با اجرت " + Core.ToSeparator(totalGoldWage) + " ریال و " + Core.ToSeparator(totalAmount) + "ریال سنگ و چرم";
                    text += " به حساب اضافه شد. ";
                    text += "\n" + "توضیحات:" + "\n" + details;
                    text += "\n";
                    text += "🌕 مانده بدهی طلایی: " + x.GoldDebt + " گرم" + "\n";
                    text += "💵 مانده بدهی: " + Core.ToSeparator(x.RialDebt) + " ریال" + "\n";
                    if (x.Description != null && x.Description != "")
                    {
                        text += "توضیح: " + x.Description + "\n";
                    }
                    textList.Add(text);
                });
                break;
            }
            return(textList);
        }