public int Save(Models.MJournal model) { Common.Logger l = new Common.Logger(); string ClassName = "CJournal"; try { DB.Journal bs = new DB.Journal(); bs.id = Convert.ToInt32(model.id); bs.acc_id = Convert.ToInt32(model.acc_id); bs.amount = Convert.ToInt32(model.amount); bs.des = model.des; bs.type = model.type; bs.e_date = Convert.ToDateTime(model.e_date); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] acc_id[" + model.acc_id + "] amount[" + model.amount + "] des[" + model.des + "] type[" + model.type + "] e_date[" + model.e_date + "]"); obj.Journals.InsertOnSubmit(bs); 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); } }
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 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); } }