public static AccessRights InsertCompProfIntoDb(CompanyProfile pro, string pathToDatabase) { AccessRights rights; if (pro.CompanyName == "SUSPENDED") { PerformSuspenedAction(pathToDatabase); } using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table <CompanyInfo>().ToList <CompanyInfo>(); var list3 = db.Table <AdPara>().ToList <AdPara>(); var list4 = db.Table <AdNumDate> ().Where(x => x.Year == DateTime.Now.Year && x.Month == DateTime.Now.Month).ToList <AdNumDate> (); CompanyInfo cprof = null; if (list2.Count > 0) { cprof = list2 [0]; } else { cprof = new CompanyInfo(); } rights = Utility.GetAccessRightsByString(pro.WCFUrl); cprof.Addr1 = pro.Addr1; cprof.Addr2 = pro.Addr2; cprof.Addr3 = pro.Addr3; cprof.Addr4 = pro.Addr4; cprof.CompanyName = pro.CompanyName; cprof.Fax = pro.Fax; cprof.GSTNo = pro.GSTNo; cprof.HomeCurr = pro.HomeCurr; cprof.IsInclusive = pro.IsInclusive; cprof.RegNo = pro.RegNo; cprof.SalesTaxDec = pro.SalesTaxDec; cprof.AllowDelete = pro.AllowDelete; cprof.AllowEdit = pro.AllowEdit; cprof.WCFUrl = pro.WCFUrl; cprof.SupportContat = pro.SupportContat; cprof.ShowTime = rights.IsShowPrintTime; cprof.AllowClrTrxHis = pro.AllowClrTrxHis; cprof.NotEditAfterPrint = pro.NoEditAfterPrint; cprof.Tel = pro.Tel; if (list2.Count == 0) { db.Insert(cprof); } else { db.Update(cprof); } AdPara apara = null; if (list3.Count == 0) { apara = new AdPara(); } else { apara = list3 [0]; } apara.Prefix = pro.Prefix; apara.RunNo = pro.RunNo; apara.Warehouse = pro.WareHouse; //new added V2 apara.CNPrefix = pro.CNPrefix; apara.CNRunNo = pro.CNRunNo; apara.DOPrefix = pro.DOPrefix; apara.DORunNo = pro.DORunNo; apara.SOPrefix = pro.SOPrefix; apara.SORunNo = pro.SORunNo; apara.FooterNote = pro.InvTitle; if (list3.Count == 0) { apara.ReceiptTitle = "TAX INVOICE"; db.Insert(apara); } else { db.Update(apara); } AdNumDate info = null; if (list4.Count == 0) { info = new AdNumDate(); info.Year = DateTime.Now.Year; info.Month = DateTime.Now.Month; info.RunNo = pro.RunNo; info.TrxType = "INV"; db.Insert(info); } } return(rights); }