Beispiel #1
0
        public int Save(Models.MBankAccount model)
        {
            Common.Logger l = new Common.Logger();
            //  string ClassName = "CBankAccount";
            try
            {
                DB.BankAccount bs = new DB.BankAccount();
                bs.id              = Convert.ToInt32(model.id);
                bs.BankId          = Convert.ToInt32(model.BankId);
                bs.AccountNumber   = model.accountNumber;
                bs.AccountTitle    = model.Accounttitle;
                bs.AccountHolderId = model.AccountHolderId;
                bs.BeginDate       = model.BeginDate;
                bs.OpeningBalance  = model.OpeningBalance;
                bs.Balance         = model.Balance;
                bs.WareHouseId     = Convert.ToInt32(model.WareHouseId);
                //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] BankId[" + model.BankId + "] AccountNumber[" + model.accountNumber + "] AccountTitle[" + model.Accounttitle + "] AccountHolderId [ " + model.AccountHolderId + "] BeginDate [ " + model.BeginDate + " ] ");
                obj.BankAccounts.InsertOnSubmit(bs);
                obj.SubmitChanges();


                Classes.CJournal cj = new CJournal();
                DB.Journal       j  = new DB.Journal();
                j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.OwnerEquity);
                j.amount = Convert.ToSingle(bs.OpeningBalance);
                j.des    = "Opened Bank Account with name[" + bs.AccountTitle + "] ";
                j.e_date = Convert.ToDateTime(bs.BeginDate);
                j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                obj.Journals.InsertOnSubmit(j);
                obj.SubmitChanges();

                j        = new DB.Journal();
                j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash);
                j.amount = Convert.ToSingle(bs.OpeningBalance);
                j.des    = "Opened Bank Account with name[" + bs.AccountTitle + "] ";
                j.e_date = Convert.ToDateTime(bs.BeginDate);
                j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                obj.Journals.InsertOnSubmit(j);
                obj.SubmitChanges();

                //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch
            {
                //l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
            public List <Models.MViewModels.MGeneralJournal> GetAll()
            {
                List <Models.MViewModels.MGeneralJournal> gj = new List <Models.MViewModels.MGeneralJournal>();

                Classes.CJournal cj = new CJournal();
                Models.MViewModels.MGeneralJournal mg  = new Models.MViewModels.MGeneralJournal();
                List <Models.MJournal>             Get = new List <Models.MJournal>();

                Dictionary <int, string> Accounts = new Dictionary <int, string>();

                foreach (Common.Constants.Accounts.ChartOfAccounts
                         item in
                         (Common.Constants.Accounts.ChartOfAccounts[])
                         Enum.GetValues(typeof(Common.Constants.Accounts.ChartOfAccounts)))
                {
                    Accounts.Add((int)item, item.ToString());
                }
                Get = cj.GetAll();
                foreach (var item in Get)
                {
                    mg           = new Models.MViewModels.MGeneralJournal();
                    mg.AccountId = item.acc_id;
                    string AccountName = (from o in Accounts
                                          where o.Key == Convert.ToInt32(item.acc_id)
                                          select o.Value.ToString())
                                         .FirstOrDefault();
                    mg.AccountName = AccountName;
                    if (item.type == Common.Constants.Accounts.Type.Credit.ToString())
                    {
                        mg.Credit = item.amount.ToString();
                        mg.Debit  = "0";
                    }
                    else
                    {
                        mg.Debit  = item.amount;
                        mg.Credit = "0";
                    }
                    mg.Description = item.des;
                    mg.Date        = item.e_date;
                    gj.Add(mg);
                }

                return(gj);
            }
Beispiel #3
0
        public int Save(Models.MSaleTransactions model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CSaleTransaction";

            try
            {
                DB.Transaction1 bs = new DB.Transaction1();
                bs.id              = Convert.ToInt32(model.id);
                bs.ProductID       = Convert.ToInt32(model.ProductID);
                bs.CostPrice       = model.CostPrice;
                bs.SalePrice       = model.SalePrice;
                bs.units           = model.units;
                bs.TransactionType = model.transactionType;
                bs.VendorID        = model.VendorID;
                bs.ClientID        = model.clientID;
                bs.OrderId         = Convert.ToInt32(model.OrderId);
                bs.WareHouseId     = Convert.ToInt32(model.WareHouseId);
                bs.date            = model.date;

                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductID[" + model.ProductID + "] CostPrice[" + model.CostPrice + "] SalePrice[" + model.SalePrice + "] units [ " + model.units + "] TransactionType [ " + model.transactionType + " ]  ClientID [ " + model.clientID + " ] VendorID [ " + model.VendorID + " ] date [ " + model.date + " ]");
                obj.Transaction1s.InsertOnSubmit(bs);
                obj.SubmitChanges();


                if (model.transactionType == Common.Constants.SaleTransactions.Addition.ToString())
                {
                    Classes.CJournal cj = new CJournal();
                    DB.Journal       j  = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units)) - Convert.ToSingle(model.Discount);
                    j.des    = "Purchased Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    if (Convert.ToSingle(model.Discount) > 0)
                    {
                        j        = new DB.Journal();
                        j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.PurchaseDiscount);
                        j.amount = Convert.ToSingle(model.Discount);
                        j.des    = "Purchased Inventory Discount [" + bs.units + "] ";
                        j.e_date = Convert.ToDateTime(model.date);
                        j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        obj.Journals.InsertOnSubmit(j);
                        obj.SubmitChanges();
                    }


                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Purchased Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();
                }
                else if (model.transactionType == Common.Constants.SaleTransactions.Deduction.ToString())
                {
                    Classes.CJournal cj = new CJournal();
                    DB.Journal       j  = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units)) - Convert.ToSingle(model.Discount);
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    if (Convert.ToSingle(model.Discount) > 0)
                    {
                        j        = new DB.Journal();
                        j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalesDiscount);
                        j.amount = Convert.ToSingle(model.Discount);
                        j.des    = "Sold Inventory Discount [" + bs.units + "] ";
                        j.e_date = Convert.ToDateTime(model.date);
                        j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        obj.Journals.InsertOnSubmit(j);
                        obj.SubmitChanges();
                    }


                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Sales);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();



                    cj       = new CJournal();
                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.CostOfGoodsSold);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();
                }


                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }