private bool ShowEmptyScreen() { if (CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor()) { return false; } if (showEmptyScreen.Get("communityScreen" + TenantProvider.CurrentTenantID) != null) { return false; } var q = new SqlExp(string.Format(@"select exists(select 1 from blogs_posts where tenant = {0}) or " + "exists(select 1 from bookmarking_bookmark where tenant = {0}) or exists(select 1 from events_feed where tenant = {0}) or " + "exists(select 1 from forum_category where tenantid = {0})", CoreContext.TenantManager.GetCurrentTenant().TenantId)); using (var db = new DbManager("community")) { var hasacitvity = db.ExecuteScalar<bool>(q); if (hasacitvity) { showEmptyScreen.Insert("communityScreen" + TenantProvider.CurrentTenantID, new object(), TimeSpan.FromMinutes(30)); } return !hasacitvity; } }
public void UpdateCompanyAndParticipantsStatus(int companyID, int contactTypeid) { if (companyID <= 0 || contactTypeid < 0) throw new ArgumentException(); using (var db = GetDb()) using (var tx = db.BeginTransaction()) { var query = new SqlExp(String.Format(@"update crm_entity_contact tbl_L inner join crm_contact tbl_R on tbl_L.entity_id = tbl_R.id set tbl_R.status_id={0} where tbl_L.entity_type = {1} and tbl_L.contact_id = {2}", contactTypeid, (int)EntityType.Person, companyID)); db.ExecuteNonQuery(query); db.ExecuteNonQuery(Update("crm_contact") .Set("status_id", contactTypeid) .Where(Exp.Eq("id", companyID))); tx.Commit(); } }
public Boolean IsExist(int invoiceID, DbManager db) { var q = new SqlExp( string.Format(@"select exists(select 1 from crm_invoice where tenant_id = {0} and id = {1})", TenantID, invoiceID)); return db.ExecuteScalar<bool>(q); }
public Boolean CanDelete(int invoiceTaxID) { var itemQuery = new SqlExp( string.Format(@"select count(*) from crm_invoice_item where tenant_id = {0} and (invoice_tax1_id = {1} or invoice_tax2_id = {1})", TenantID, invoiceTaxID)); var lineQuery = new SqlExp( string.Format(@"select count(*) from crm_invoice_line where tenant_id = {0} and (invoice_tax1_id = {1} or invoice_tax2_id = {1})", TenantID, invoiceTaxID)); using (var db = GetDb()) { return db.ExecuteScalar<int>(itemQuery) == 0 && db.ExecuteScalar<int>(lineQuery) == 0; } }
public Boolean IsExist(int invoiceTaxID) { var q = new SqlExp( string.Format(@"select exists(select 1 from crm_invoice_tax where tenant_id = {0} and id = {1})", TenantID, invoiceTaxID)); using (var db = GetDb()) { return db.ExecuteScalar<bool>(q); } }
public Boolean CanDelete(int contactID) { var q = new SqlExp( string.Format(@"select count(*) from crm_invoice where tenant_id = {0} and (contact_id = {1} or consignee_id = {1})", TenantID, contactID)); using (var db = GetDb()) { return db.ExecuteScalar<int>(q) == 0; } }
public bool IsExist(int id) { var q = new SqlExp( string.Format(@"select exists(select 1 from crm_field_description where tenant_id = {0} and id = {1})", TenantID, id)); using (var db = GetDb()) { return db.ExecuteScalar<bool>(q); } }
public Boolean IsExist(int id) { var q = new SqlExp( string.Format(@"select exists(select 1 from crm_deal_milestone where tenant_id = {0} and id = {1})", TenantID, id)); using (var db = GetDb()) { return db.ExecuteScalar<bool>(q); } }
public bool HasActivity() { var q = new SqlExp(string.Format(@"select exists(select 1 from crm_case where tenant_id = {0}) or " + "exists(select 1 from crm_deal where tenant_id = {0}) or exists(select 1 from crm_task where tenant_id = {0}) or " + "exists(select 1 from crm_contact where tenant_id = {0})", TenantID)); using (var db = GetDb()) { return db.ExecuteScalar<bool>(q); } }
public Boolean CanDelete(int invoiceItemID) { var q = new SqlExp( string.Format(@"select count(*) from crm_invoice_line where tenant_id = {0} and invoice_item_id = {1}", TenantID, invoiceItemID)); using (var db = GetDb()) { return db.ExecuteScalar<int>(q) == 0; } }