public static BO_Users Login(HttpSessionStateBase session, string UserName, string Password, out Constants.LoginResult result)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                BO_Users user = new BO_Users();

                var obj = db.Users.Where(x => x.UserName == UserName && x.Password == Password && x.IsActive == true).FirstOrDefault();
                if (obj != null)
                {
                    result         = Constants.LoginResult.Success;
                    user.firstName = obj.FirstName;
                    user.lastName  = obj.LastName;
                    user.id        = obj.Id;
                    user.phone     = obj.Phone;
                    user.userId    = obj.UserName;
                    // user.adminRights = obj.AdminRights??false;
                }
                else
                {
                    result = Constants.LoginResult.WrongPwd;
                }

                return(user);
            }
        }
        public static List <BO_Customerlist> GetSubCustomerList(int typeID)
        {
            List <BO_Customerlist> obj_Sub = null;

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                obj_Sub = (from subs in db_aa.Subscriptions
                           join cus in db_aa.Customers on subs.CustId equals cus.Id
                           where cus.IsActive == true && subs.IsActive == true
                           select new BO_Customerlist
                {
                    Id = cus.Id,
                    Name = (cus.FirstName ?? "") + " " + (cus.LastName ?? ""),
                    DueDate = subs.DueDate,
                    SubscriptionAmount = subs.SubscriptionAmount,
                    FirstName = cus.FirstName ?? "",
                    LastName = cus.LastName ?? "",
                    Email = cus.Email ?? "",
                    StartDate = cus.StartDate != null ? cus.StartDate.ToString() : "",
                    PhoneNo = cus.Phone ?? "",
                }).ToList();



                return(obj_Sub.OrderBy(x => x.Name).ToList());
            }
        }
        public static string SaveUser(BO_Users _user, int UserID)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                try
                {
                    //var objcheck = db.Users.Where(x => x.UserName.ToLower() == _user.userId.ToLower()).FirstOrDefault();
                    //if (objcheck != null)
                    //{
                    //    return "User Already Exists";
                    //}

                    var obj = _user.id == 0 ? new ApprosysAccDB.User() : db.Users.Where(x => x.Id == _user.id).FirstOrDefault();
                    if (_user.id > 0)
                    {
                        var checkCust = db.Users.Where(x => x.UserName.ToLower() == _user.userId.ToLower() && x.Id != _user.id && x.IsActive == true).FirstOrDefault();
                        if (checkCust != null)
                        {
                            return("UserID Already Exists");
                        }
                    }
                    if (obj != null && obj.Id > 0)
                    {
                        obj.ModifiedBy = UserID;
                        obj.ModifiedOn = BL_Common.GetDatetime();
                    }
                    obj.Id = _user.id;

                    obj.LastName  = _user.lastName ?? "";
                    obj.FirstName = _user.firstName ?? "";
                    obj.UserName  = _user.userId;
                    obj.Password  = _user.password;
                    obj.Phone     = _user.phone;
                    obj.Email     = _user.email;
                    obj.IsActive  = true;
                    obj.Address   = _user.address;


                    obj.IsActive    = true;
                    obj.AdminRights = _user.adminRights;
                    if (obj.Id == 0)
                    {
                        obj.CreatedBy = UserID;
                        obj.CreatedOn = BL_Common.GetDatetime();
                        var objcheck = db.Users.Where(x => x.UserName.ToLower() == _user.userId.ToLower() && x.Id != _user.id && x.IsActive == true).FirstOrDefault();
                        if (objcheck != null)
                        {
                            return("UserID Already Exists");
                        }
                        db.Users.Add(obj);
                    }

                    db.SaveChanges();
                    return("success");

                    // return "Insertion Failed";
                }
                catch { throw; }
            }
        }
示例#4
0
        public static List <BO_Expense> GetExpense(int coaID)
        {
            List <BO_Expense> obj = null;

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                switch (coaID)
                {
                case 10:
                    obj = (from _cust in db_aa.Customers where _cust.IsActive select new BO_Expense {
                        id = _cust.Id, name = ((_cust.FirstName ?? "") + "" + (_cust.LastName ?? ""))
                    }).ToList();
                    break;

                case 12:
                    obj = (from _vend in db_aa.Vendors where _vend.IsActive ?? true select new BO_Expense {
                        id = _vend.ID, name = ((_vend.FirstName ?? "") + "" + (_vend.LastName ?? ""))
                    }).ToList();
                    break;

                default:
                    obj = (from _coa in db_aa.Acc_COA where (_coa.IsActive == true && _coa.PId == coaID)select new BO_Expense {
                        id = _coa.CoaId, name = (_coa.TreeName ?? "")
                    }).ToList();
                    break;
                }


                return(obj);
            }
        }
        public static List <BO_UnpaidCreditCustomerInvoice> GetUnPaidCreditCustomerInvoices(int custID)
        {
            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                var lst = db_aa.Credit_GetUnPaidCustomersInvoice(custID);
                List <BO_UnpaidCreditCustomerInvoice> lst_cust = new List <BO_UnpaidCreditCustomerInvoice>();
                BO_UnpaidCreditCustomerInvoice        obj;
                var salePersons     = GetSalePersonNameById(custID);
                var partialPayments = GetAllPartialPayments().GroupBy(x => x.InvoiceNum).ToDictionary(x => x.Key);
                foreach (var _creditCustomer in lst.ToList())
                {
                    obj               = new BO_UnpaidCreditCustomerInvoice();
                    obj.invoiceNo     = _creditCustomer.InvoiceNo;
                    obj.salePerson    = salePersons[custID];
                    obj.sellDate      = _creditCustomer.SalesDate.Value;
                    obj.netAmount     = _creditCustomer.Amount ?? 0;
                    obj.paidAmount    = 0;
                    obj.invoiceAmount = obj.netAmount;
                    if (partialPayments.ContainsKey(_creditCustomer.InvoiceNo))
                    {
                        obj.paidAmount = partialPayments[_creditCustomer.InvoiceNo].Sum(x => x.Amount);
                        obj.netAmount  = obj.invoiceAmount - obj.paidAmount;
                    }
                    if (obj.invoiceAmount > obj.paidAmount)
                    {
                        lst_cust.Add(obj);
                    }
                }


                return(lst_cust.OrderByDescending(x => (Convert.ToInt32(x.invoiceNo.Remove(0, 4)))).ToList());
            }
        }
 public static BO_Item GetItemByID(int itemId)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         var     obj   = db.Items.Where(x => x.Id == itemId).FirstOrDefault();
         BO_Item _item = new BussinessObject.BO_Item();
         if (obj != null && obj.Id > 0)
         {
             _item.id               = obj.Id;
             _item.itemCode         = obj.ItemCode ?? "";
             _item.name             = obj.Name ?? "";
             _item.unit             = obj.Unit ?? "";
             _item.minQuantity      = obj.MinQty ?? 0;
             _item.purchasePrice    = obj.PurchasePrice ?? 0;
             _item.sellPrice        = obj.SellPrice ?? 0;
             _item.description      = obj.Description ?? "";
             _item.taxPercent       = obj.TaxPercent ?? 0;
             _item.isTaxable        = obj.IsTaxable ?? false;
             _item.oilGradeId       = obj.OilGradeId ?? 0;
             _item.quantityInCarton = obj.QuantityInCarton ?? 0;
             _item.packingInLitre   = obj.PackingInLitre ?? 0m;
         }
         return(_item);
     }
 }
 public static List <KeyValuePair <int, string> > GetBankList()
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         return(db.Acc_COA.Where(x => x.PId == 104 && x.IsActive == true).Select(z => new { z.CoaId, z.TreeName }).ToDictionary(z => Convert.ToInt32(z.CoaId), q => String.Format("{0}", q.TreeName)).OrderBy(x => x.Value).ToList());
     }
 }
示例#8
0
 public static string AddNewBankAccoount(string bankName, string bankAccount, decimal?depositAmmount)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         try
         {
             var chk = db.Acc_COA.FirstOrDefault(x => x.TreeName == bankAccount);
             if (chk != null)
             {
                 return(String.Format("Account No: {0} is already exist.", bankAccount));
             }
             var acc = new Acc_COA();
             acc.PId            = 104;
             acc.CoaNo          = "";
             acc.HeadAccount    = 1;
             acc.TreeName       = bankAccount;
             acc.CoaLevel       = 2;
             acc.OpeningBalance = depositAmmount;
             acc.IsActive       = true;
             db.Acc_COA.Add(acc);
             db.SaveChanges();
             return("success");
         }
         catch (Exception ex) { throw ex; }
     }
 }
 public static List <BO_BonusRevenue> GetBonusRevenue(JQueryDataTableParamModel Param)
 {
     using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
     {
         Param.End_Date = Param.End_Date.AddDays(1);
         List <BO_BonusRevenue> lst_bonus = new List <BO_BonusRevenue>();
         //var temp = new BO_BonusRevenue();
         var lst_bonusList = (from glRevenue in db_aa.Acc_GL
                              join glAccount in db_aa.Acc_GL on glRevenue.TranId equals glAccount.TranId
                              join caRevenue in db_aa.Acc_COA on glRevenue.CoaId equals caRevenue.CoaId
                              join caAccount in db_aa.Acc_COA on glAccount.CoaId equals caAccount.CoaId
                              where caRevenue.PId == 25 && glRevenue.IsActive == true && glAccount.IsActive == true &&
                              glRevenue.ActivityTimestamp >= Param.Start_Date && glAccount.ActivityTimestamp <= Param.End_Date
                              select new BO_BonusRevenue
         {
             TransactionId = glRevenue.TranId,
             BonusAmount = glRevenue.Credit,
             Misc = glRevenue.Comments,
             activityDate = glRevenue.CreatedDate,
             BankAccount = caAccount.TreeName,
             RevenueAccount = caRevenue.TreeName,
         }).ToList();
         //foreach (var item in lst_bonusList)
         //{
         //    if (temp.TransactionId != item.TransactionId)
         //    {
         //        lst_bonus.Add(item);
         //        temp = item;
         //    }
         //}
         lst_bonus = lst_bonusList.DistinctBy(x => x.TransactionId).ToList();
         return(lst_bonus.OrderByDescending(x => x.activityDate).ToList());
     }
 }
 public static List <KeyValuePair <int, string> > GetCustomersListBySalePersonID(int salePersonID)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         return(db.Customers.Where(x => x.IsActive == true && (x.SalesPersonId == null || x.SalesPersonId == salePersonID)).Select(z => new { z.Id, z.FirstName, z.LastName }).ToDictionary(z => Convert.ToInt32(z.Id), q => String.Format("{0} {1}", q.FirstName, q.LastName)).OrderBy(x => x.Value).ToList());
     }
 }
 public static List <string> GetSalesPersonNamesByID(List <int> salePersonID)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         return(db.SalesPersons.Where(x => salePersonID.Contains(x.Id)).Select(x => x.FirstName + " " + x.LastName).ToList());
     }
 }
 public static List <BO_CreditSales> GetUnPaidCreditSales(JQueryDataTableParamModel Param)
 {
     using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
     {
         List <BO_CreditSales> lst_CreditSales = new List <BO_CreditSales>();
         //Param.Start_Date = BL_Common.GetDatetime().AddDays(-7);
         Param.End_Date = Param.End_Date.AddDays(1);
         var            lst           = db_aa.Credit_GetUnpaidCreditSales(Param.Start_Date, Param.End_Date).ToList();
         var            partiallyPaid = GetAllPartialPayments().GroupBy(x => x.InvoiceNum).ToDictionary(x => x.Key);
         BO_CreditSales obj;
         if (lst != null && lst.Count > 0)
         {
             foreach (var _sales in lst.ToList())
             {
                 obj              = new BO_CreditSales();
                 obj.invoiceNo    = _sales.InvoiceNo;
                 obj.sellDate     = _sales.SalesDate.Value;
                 obj.customerName = _sales.CustomerName;
                 obj.netAmount    = _sales.Amount ?? 0;
                 obj.customerID   = _sales.CustId;
                 if (partiallyPaid.ContainsKey(obj.invoiceNo))
                 {
                     obj.netAmount = obj.netAmount - partiallyPaid[obj.invoiceNo].Sum(x => x.Amount);
                 }
                 if (obj.netAmount > 0)
                 {
                     lst_CreditSales.Add(obj);
                 }
             }
         }
         return(lst_CreditSales.OrderByDescending(x => (Convert.ToInt32(x.invoiceNo.Remove(0, 4)))).ToList());
     }
     //   return lst_CreditSales;
 }
示例#13
0
        public static IList <BO_SubscriptoinPayment> LoadSubscriptionPaymentVoucher(JQueryDataTableParamModel Param)
        {
            List <BO_SubscriptoinPayment> lst_SubscriptionPaymentVoucherTable = new List <BO_SubscriptoinPayment>();

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                BO_SubscriptoinPayment obj;

                var lst = db_aa.GetSubscriptionVoucherList("", Param.Start_Date, Param.End_Date);
                foreach (var item in lst.ToList())
                {
                    obj              = new BO_SubscriptoinPayment();
                    obj.invoiceNo    = item.InvoiceNo;
                    obj.activityDate = item.ActivityTimestamp;
                    obj.customerName = item.Customer;
                    obj.paidAmount   = item.Amount;
                    // obj.sort = item.sort??0;
                    obj.totalDues = item.Amount;//Farooq
                    lst_SubscriptionPaymentVoucherTable.Add(obj);
                }
            }
            if (Param.SearchType != 0)
            {
            }

            // List<BO_ReceiptVoucherTable> ListtoReturn = new List<BO_ReceiptVoucherTable>();
            // ListtoReturn = lst_receiptVoucherTable;
            return(lst_SubscriptionPaymentVoucherTable);
        }
示例#14
0
        public static string SaveRevenueSales(string name, decimal cost, string code)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                var obj = db.Acc_COA.Where(x => x.PId == 101 && x.HeadAccount == 5 && x.TreeName.ToLower() == name.ToLower() && x.IsActive == true).FirstOrDefault();
                if (obj != null)
                {
                    return("Exists");
                }
                var objS = db.Acc_COA.Where(x => x.PId == 101 && x.HeadAccount == 5 && x.ServiceCode == code && x.IsActive == true).FirstOrDefault();
                if (objS != null)
                {
                    return("Code Already Exists");
                }

                var obj_COA = new ApprosysAccDB.Acc_COA();
                obj_COA.PId            = 101;
                obj_COA.HeadAccount    = 5;
                obj_COA.TreeName       = name;
                obj_COA.CoaLevel       = 2;
                obj_COA.OpeningBalance = 0;
                obj_COA.IsActive       = true;
                obj_COA.Cost           = cost;
                obj_COA.ServiceCode    = code;
                db.Acc_COA.Add(obj_COA);
                db.SaveChanges();
                return("success");
            }
        }
示例#15
0
        public static IList <BO_Equity> LoadEquityInfo(JQueryDataTableParamModel Param)
        {
            List <BO_Equity> obj = null;

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                obj = (from gl in db_aa.Acc_GL
                       join coa in db_aa.Acc_COA on gl.CoaId equals coa.CoaId
                       where gl.TranTypeId == 11 && gl.IsActive == true && coa.PId == 3

                       select new BO_Equity
                {
                    invoiceNo = gl.InvoiceNo,
                    investorName = coa.TreeName,
                    amount = ((gl.Credit != null && gl.Credit > 0) ? (gl.Credit ?? 0) : (gl.Debit ?? 0)),
                    activity = (gl.Credit != null && gl.Credit > 0) ? "Deposit" : "WithDraw",
                    activityTime = gl.ActivityTimestamp.Value,
                }).ToList();
                if (obj != null && obj.Count > 0)
                {
                    for (int i = 0; i < obj.Count; i++)
                    {
                        string _invoiceno = obj[i].invoiceNo;
                        int    _coaId     = obj[i].investorId;
                        string _accountNo = (from gl in db_aa.Acc_GL
                                             join coa in db_aa.Acc_COA on gl.CoaId equals coa.CoaId
                                             where gl.TranTypeId == 11 && gl.IsActive == true && gl.InvoiceNo == _invoiceno && gl.CoaId != _coaId
                                             select coa.TreeName).FirstOrDefault();
                        obj[i].accountNo = _accountNo;
                    }
                }
            }
            return(obj.OrderByDescending(x => (Convert.ToInt32(x.invoiceNo.Remove(0, 3)))).ToList());
        }
示例#16
0
 public static string UpdateSaleInvoice(BO_SaleInvoice pi)
 {
     //if (pi.items.GroupBy(x => x.itemID).Where(x => x.Count() > 1).Count() == 1) { return "bad request"; }
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 if (DeleteSaleInvoice(pi.invoiceNo, pi.empID, transaction, db) == "Success")
                 {
                     SaveSales(pi, transaction, db);
                 }
                 db.SaveChanges();
                 transaction.Commit();
                 return(pi.invoiceNo);
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
        public static BO_SalesPersonManagement GetSalesPersonByID(int salePersonID)
        {
            BO_SalesPersonManagement _salesPerson = new BussinessObject.BO_SalesPersonManagement();

            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                var obj = db.SalesPersons.Where(x => x.Id == salePersonID).FirstOrDefault();
                if (obj != null && obj.Id > 0)
                {
                    _salesPerson.Id             = obj.Id;
                    _salesPerson.lastName       = obj.LastName ?? "";
                    _salesPerson.firstName      = obj.FirstName ?? "";
                    _salesPerson.phone          = obj.Phone ?? "";
                    _salesPerson.email          = obj.Email ?? "";
                    _salesPerson.cnic           = obj.CNIC;
                    _salesPerson.ntn            = obj.NTN;
                    _salesPerson.openingBalance = obj.OpeningBalance ?? 0;
                    _salesPerson.startDate      = obj.StartDate;
                    _salesPerson.misc           = obj.Misc ?? "";
                    obj.ModifiedOn = BL_Common.GetDatetime();
                }
                if (_salesPerson != null)
                {
                    _salesPerson.customersIDs = db.Customers.Where(x => x.SalesPersonId == salePersonID).Select(x => x.Id).ToList() ?? null;
                }
            }
            return(_salesPerson);
        }
        private static List <CustomerPaymentHistory> GetPaymentHistoryData(JQueryDataTableParamModel Param, int userId)
        {
            DateTime startDateParameter = Param.Start_Date == DateTime.MinValue ? DateTime.Now.AddDays(-5) : Param.Start_Date.AddDays(-1);
            DateTime endDateParameter   = Param.End_Date == DateTime.MinValue ? DateTime.Now.AddDays(5) : Param.End_Date.AddDays(1);
            List <CustomerPaymentHistory> customerPaymentHistoryList = new List <CustomerPaymentHistory>();

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                string userName = db_aa.Users.FirstOrDefault(x => x.Id == userId).UserName;
                var    List     = (from cus in db_aa.Customers
                                   //join u in db_aa.Users on u.SalesPersonId equals sp.Id
                                   //join itm in db_aa.Items on cus.TypeId equals itm.ItemTypeId
                                   join gl in db_aa.Acc_GL on cus.Id equals gl.CustId
                                   where gl.Credit > 0 && gl.IsActive == true && gl.CoaId == 10 && gl.ActivityTimestamp >= startDateParameter && gl.ActivityTimestamp <= endDateParameter
                                   select new CustomerPaymentHistory
                {
                    glId = gl.GlId,
                    tranId = gl.TranId,
                    customerId = cus.Id,
                    customerName = cus.FirstName + " " + cus.LastName,
                    invoiceNo = gl.InvoiceNo,
                    activityTimestamp = gl.ActivityTimestamp,
                    amount = gl.Credit,
                    recievedBy = userName,
                    userID = userId
                }).ToList();
                customerPaymentHistoryList = List;
            }
            return(customerPaymentHistoryList.OrderByDescending(x => (x.activityTimestamp)).ToList());
        }
示例#19
0
        public string ClearSuspendedDuesofCustomer(int SubCustId)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                DateTime?subExclusionDate   = BL_Common.GetDatetime();
                var      totalpaidcustomer  = db.usp_GetTotalPaidofCustomer(SubCustId).FirstOrDefault();//.Select (x => new { x.CustId, x.TotPaid, x.LastPaid });
                decimal  _totpaid           = (totalpaidcustomer == null ? 0 : (totalpaidcustomer.TotPaid ?? 0));
                var      totalduesfromstart = db.usp_GetSubDuesofCustomer(SubCustId).ToList().Select(x => new { x.CustId, x.SubscriptionDueDate, x.Debit, x.AllDueBefore }).ToList();
                for (int i = 0; i < totalduesfromstart.Count(); i++)
                {
                    if (_totpaid <= totalduesfromstart[i].AllDueBefore)
                    {
                        subExclusionDate = totalduesfromstart[i].SubscriptionDueDate;
                        //string t= "Update  SubscriptionExcludingDates SET SubDisableStartDate = '" + subExclusionDate + "' where CustId = " + SubCustId+ " and SubDisableEndDate = '"+new DateTime(2015,12,31).Date.Date+"'";
                        db.Database.ExecuteSqlCommand("Update  SubscriptionExcludingDates SET SubDisableStartDate = '" + subExclusionDate + "' where CustId=" + SubCustId + " and SubDisableEndDate= '2050 - 12 - 31 00:00:00.000'");

                        break;
                    }
                }
                Func <DateTime, string> act = new Func <DateTime, string>(BL_SubscriptionManagement.ValidateDueDates);
                act.BeginInvoke(DateTime.Now, null, null);

                //var lst_totalpaid = (from GL in db.Acc_GL
                //                     join C in db.Customers on GL.CustId equals C.Id
                //                     join S in db.Subscriptions on C.Id equals S.CustId
                //                     where GL.IsActive == true && C.IsActive == true && S.IsActive == true
                //                     select new
                //                     {
                //                         tranid = GL.TranId,
                //                         credit = GL.Credit,
                //                         subDueDate = GL.SubscriptionDueDate,
                //                         debit = GL.Debit,
                //                     }
                //                ).ToList();
                //decimal totalpaid = lst_totalpaid.Sum(x => x.credit).Value;
                //db.Database.ExecuteSqlCommand("Update  SubscriptionExcludingDates SET SubDisableStartDate = '" + BL_Common.GetDatetime() + "' where CustId=" + SubCustId);
                //  db.Database.ExecuteSqlCommand("Update  Subscription SET StartDate = '" + BL_Common.GetDatetime() + "' where Id=" + SubCustId);
            }

            //var lst_sed = db_aa.SubscriptionExcludingDates.Where(x => x.CustId == SubCustId).ToList();
            //if (lst_sed != null && lst_sed.Count > 0)
            //{
            //    List<BO_SubscriptionExcludingDates> ll = new List<BO_SubscriptionExcludingDates>();
            //    for (int i = 0; i < lst_sed.Count; i++)
            //    {


            //        BO_SubscriptionExcludingDates _Sed = new BO_SubscriptionExcludingDates();
            //        //_Sed.subDisableStartDate = BL_Common.GetDatetime();
            //        //_Sed.sedisActive = true;

            //        db_aa.SubscriptionExcludingDates.Add(_Sed);
            //        db_aa.SaveChanges();
            //    }
            //    db_aa.SaveChanges();

            //}

            return("success");
        }
示例#20
0
 public static List <KeyValuePair <int, string> > GetOilGradeData()
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         return(db.OilGrades.Where(x => x.IsActive == true).Select(z => new { z.Id, z.OilGade }).ToDictionary(z => Convert.ToInt32(z.Id), q => String.Format("{0}", q.OilGade)).OrderBy(x => x.Value).ToList());
     }
 }
        public static BO_BonusRevenue GetBonusRecordById(int transId)
        {
            BO_BonusRevenue obj_br = null;

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                var objBonus = (from glRevenue in db_aa.Acc_GL
                                join glAccount in db_aa.Acc_GL on glRevenue.TranId equals glAccount.TranId
                                join caRevenue in db_aa.Acc_COA on glRevenue.CoaId equals caRevenue.CoaId
                                join caAccount in db_aa.Acc_COA on glAccount.CoaId equals caAccount.CoaId
                                where
                                caRevenue.PId == 25 && glRevenue.IsActive == true && glAccount.IsActive == true
                                //&& glRevenue.TranId == transId

                                select new BO_BonusRevenue
                {
                    activityDate = glRevenue.CreatedDate,
                    BankAccount = caAccount.CoaId.ToString(),
                    RevenueAccount = caRevenue.CoaId.ToString(),
                    BonusAmount = glRevenue.Credit,
                    TransactionId = glRevenue.TranId,
                    Misc = glRevenue.Comments ?? ""
                }).ToList();
                obj_br = objBonus.FirstOrDefault(x => x.TransactionId == transId);
            }
            return(obj_br);
        }
        public static string SaveCustomer(BO_Customers _customer, int UserID)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                try
                {
                    var obj = _customer.id == 0 ? new ApprosysAccDB.Customer() : db.Customers.Where(x => x.Id == _customer.id && x.IsActive == true).FirstOrDefault();
                    if (_customer.id > 0)
                    {
                        var checkCust = db.Customers.Where(x => x.LastName.ToLower() == _customer.lastName.ToLower() && x.FirstName.ToLower() == _customer.firstName.ToLower() && x.Id != _customer.id && x.IsActive == true).FirstOrDefault();
                        if (checkCust != null)
                        {
                            return("Customer Already Exists");
                        }
                    }

                    if (obj != null && obj.Id > 0)
                    {
                        obj.ModifiedBy = UserID;
                        obj.ModifiedOn = BL_Common.GetDatetime();
                    }
                    obj.Id            = _customer.id;
                    obj.LastName      = _customer.lastName;
                    obj.FirstName     = _customer.firstName;
                    obj.SalesPersonId = _customer.salesPerson;
                    obj.Phone         = _customer.phone ?? "";
                    obj.CNIC          = _customer.cnic ?? "";
                    obj.NTN           = _customer.ntn ?? "";

                    obj.Email = _customer.email;
                    if (_customer.startDate == null)
                    {
                        _customer.startDate = DateTime.Now.Date;
                    }
                    obj.StartDate = _customer.startDate;

                    obj.OpeningBalance = _customer.openingBalance;
                    obj.Misc           = _customer.misc;
                    obj.TypeId         = 1;
                    if (obj.Id == 0)
                    {
                        obj.CreatedBy = UserID;
                        obj.CreatedOn = BL_Common.GetDatetime();
                        var objcheck = db.Customers.Where(x => x.LastName.ToLower() == _customer.lastName.ToLower() && x.FirstName.ToLower() == _customer.firstName.ToLower() && x.IsActive == true).FirstOrDefault();
                        if (objcheck != null)
                        {
                            return("Customer Already Exists");
                        }
                        db.Customers.Add(obj);
                    }
                    obj.IsActive = true;
                    db.SaveChanges();
                    return(obj.Id.ToString());

                    // return "Insertion Failed";
                }
                catch { throw; }
            }
        }
示例#23
0
 public static string DeletePurchaseInvoice(string invoiceNo, int empID)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         var obj = db.DeletePurchase(invoiceNo, empID);
     }
     return("success");
 }
 public static string GetExpenseByID(int id)
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         var obj = db.Acc_COA.Where(x => x.PId == 19 && x.HeadAccount == 4 && x.CoaId == id).FirstOrDefault();
         return(obj.TreeName);
     }
 }
示例#25
0
 public static string GetItemNameByItemId(int ItemId)
 {
     using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
     {
         string name = db_aa.Items.Where(x => x.Id == ItemId).FirstOrDefault().Name.ToString();
         return(name);
     }
 }
示例#26
0
 public static List <KeyValuePair <string, string> > GetSaleInvoicesList()
 {
     using (AprosysAccountingEntities db = new AprosysAccountingEntities())
     {
         DateTime Start_Date = new DateTime(2000, 01, 01);
         DateTime End_Date   = DateTime.Now.AddDays(1);
         return(db.GetSaleInvoiceList(Start_Date, End_Date).Select(z => new { z.InvoiceNo, z.cstName }).ToDictionary(z => z.InvoiceNo, q => String.Format("{0}, {1}", q.InvoiceNo, q.cstName)).OrderBy(x => x.Value).ToList());
     }
 }
示例#27
0
        //public static string SaveSuspendedDuesofCustomer(int CustID,int EmpId)
        //{
        //  decimal pendingdues=  BL_Customer.GetCustomerBalance(CustID)??0;
        //    if (pendingdues > 0)
        //    {
        //        BO_ReceiptVoucher _rvoucher = new BO_ReceiptVoucher();
        //        _rvoucher.rCustomerId = CustID;
        //        _rvoucher.rRecived = pendingdues;
        //        _rvoucher.empID = EmpId;
        //        _rvoucher.rComments = "Clear Pending Dues of Subscription Customer";
        //        _rvoucher.rActivityDate = BL_Common.GetDatetime();
        //        _rvoucher.TypeId = 2;
        //        _rvoucher.rbalance = pendingdues;//its not enter in db , sets it for Acc REC entry

        //        SaveReceiptVoucher(_rvoucher);
        //    }
        //    return "success";
        //}
        public static string SaveReceiptVoucher(BO_ReceiptVoucher _rvoucher)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        int transType = (int)Constants.TransactionTypes.ReceiptVoucher;
                        _rvoucher.invoiceNo = Util.GetNextVoucher(transType);
                        bool isPostPaid = _rvoucher.TypeId == 2 ? true : false;
                        //Parent Entry

                        var GLParent = new Acc_GL()
                        {
                            CoaId = 0, UserId = _rvoucher.empID, Comments = _rvoucher.rComments, CustId = _rvoucher.rCustomerId, ActivityTimestamp = _rvoucher.rActivityDate, TranTypeId = transType, Debit = _rvoucher.rRecived, Credit = _rvoucher.rRecived, InvoiceNo = _rvoucher.invoiceNo, IsActive = true, IsPostpaid = isPostPaid, CreatedBy = _rvoucher.empID, ModifiedBy = _rvoucher.empID, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                        };
                        string InvoiceID = GLParent.InvoiceNo;
                        db.Acc_GL.Add(GLParent);
                        db.SaveChanges();
                        //Acc Receiveable for Type=1 , Subscrtiption Receiveable=2
                        if (_rvoucher.TypeId == 1 || (_rvoucher.TypeId == 2 && _rvoucher.rbalance != 0))
                        {
                            //Acc Receivable
                            var GLpaid = new Acc_GL()
                            {
                                TranId = GLParent.GlId, UserId = _rvoucher.empID, CoaId = 10, CustId = _rvoucher.rCustomerId, ActivityTimestamp = _rvoucher.rActivityDate, TranTypeId = transType, InvoiceNo = _rvoucher.invoiceNo, IsActive = true, Credit = _rvoucher.rRecived, IsPostpaid = isPostPaid, CreatedBy = _rvoucher.empID, ModifiedBy = _rvoucher.empID, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                            };
                            db.Acc_GL.Add(GLpaid);
                        }
                        else
                        {
                            //Subscription Sales
                            var GLSalesSub = new Acc_GL()
                            {
                                TranId = GLParent.GlId, UserId = _rvoucher.empID, CoaId = 100, CustId = _rvoucher.rCustomerId, ActivityTimestamp = _rvoucher.rActivityDate, TranTypeId = transType, InvoiceNo = _rvoucher.invoiceNo, IsActive = true, Credit = _rvoucher.rRecived, IsPostpaid = isPostPaid, CreatedBy = _rvoucher.empID, ModifiedBy = _rvoucher.empID, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                            };
                            db.Acc_GL.Add(GLSalesSub);
                        }
                        //Cash Entry
                        var GLCash = new Acc_GL()
                        {
                            TranId = GLParent.GlId, UserId = _rvoucher.empID, CoaId = 11, CustId = _rvoucher.rCustomerId, ActivityTimestamp = _rvoucher.rActivityDate, TranTypeId = transType, InvoiceNo = _rvoucher.invoiceNo, IsActive = true, Debit = _rvoucher.rRecived, IsPostpaid = isPostPaid, CreatedBy = _rvoucher.empID, ModifiedBy = _rvoucher.empID, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                        };
                        db.Acc_GL.Add(GLCash);
                        db.SaveChanges();
                        transaction.Commit();
                        return(InvoiceID);
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
        }
示例#28
0
 public static List <KeyValuePair <int, string> > GetActingAccounts()
 {
     using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
     {
         List <KeyValuePair <int, string> > accL = new List <KeyValuePair <int, string> >();
         accL = db_aa.Acc_COA.Where(x => x.CoaId == 132 || x.CoaId == 133).ToList().Select(x => new KeyValuePair <int, string>(x.CoaId, x.TreeName)).ToList();
         return(accL);
     }
 }
示例#29
0
        public static List <Report_GetPurchaseInvoice_Result> GetPurchaseByInvoiceId(string _purchaseInvoiceId)
        {
            List <Report_GetPurchaseInvoice_Result> _si = new List <Report_GetPurchaseInvoice_Result>();

            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                _si = db.Report_GetPurchaseInvoice(_purchaseInvoiceId).ToList();
            }
            return(_si);
        }
示例#30
0
        public static string GetNextVoucher(int transTypeID)
        {
            using (AprosysAccountingEntities db = new AprosysAccountingEntities())
            {
                string voucher = BL_Common.GetLastVoucher(transTypeID);
                string preFix  = String.Empty;
                switch (transTypeID)
                {
                case 1:
                    preFix = "PNV-";
                    break;

                case 2:
                    preFix = "SNV-";
                    break;

                case 3:
                    preFix = "RCT-";
                    break;

                case 4:
                    preFix = "PMT-";
                    break;

                case 5:
                    preFix = "SUBS-";
                    break;

                case 6:
                    preFix = "BT-";
                    break;

                case 7:
                    preFix = "STI-";
                    break;

                case 8:
                    preFix = "STO-";
                    break;

                case 11:
                    preFix = "EQ-";
                    break;

                default:
                    break;
                }
                if (String.IsNullOrEmpty(voucher))
                {
                    return(preFix + "1");
                }
                var increment = Convert.ToInt32(voucher.Split('-')[1]) + 1;
                return(preFix + increment);
            }
        }