public void CheckFreeFields(int id, CRMTables crmTables, UserConfig UC) { G g = new G(); string query = g.GroupsSecure(UC); if (query.Length > 0) { query = " GROUPS LIKE '%|" + UC.UserGroupId + "|%'"; } string sqlString; sqlString = "SELECT * FROM ADDEDFIELDS WHERE TABLENAME=" + (byte)crmTables + " AND (" + query + ") ORDER BY VIEWORDER"; DataSet ds = DatabaseConnection.CreateDataset(sqlString); if (ds.Tables[0].Rows.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<table width=\"100%\"><tr><td class=\"normal Bbot\"><br><b>{0}</b></td></tr></table>", Root.rm.GetString("Bcotxt50")); sb.Append("<table width=\"45%\" class=\"normal\">"); foreach (DataRow dr in ds.Tables[0].Rows) { sb.Append(FreeFieldType(crmTables, (FreeFieldsType)dr["type"], dr["name"].ToString(), int.Parse(dr["id"].ToString()), id, dr["Items"].ToString())); } sb.Append("</table>"); strOut = sb.ToString(); } }
public void ViewFreeFields(int id, CRMTables crmTables, UserConfig UC) { G g = new G(); string query = g.GroupsSecure(UC); if (query.Length > 0) { query = " groups like '%|" + UC.UserGroupId + "|%'"; } string sqlString; sqlString = "SELECT * FROM ADDEDFIELDS WHERE TABLENAME=" + (byte)crmTables + " AND (" + query + ") ORDER BY VIEWORDER"; DataSet ds = DatabaseConnection.CreateDataset(sqlString); if (ds.Tables[0].Rows.Count > 0) { StringBuilder S = new StringBuilder(); S.AppendFormat("<table width=\"100%\"><tr><td class=\"normal Bbot\"><br><b>{0}</b></td></tr></table>", Root.rm.GetString("Bcotxt50")); S.Append("<table width=\"45%\" class=\"normal\">"); foreach (DataRow dr in ds.Tables[0].Rows) { bool isParentCrossed = true; DataSet Q = DatabaseConnection.CreateDataset("SELECT PARENTFIELD,PARENTFIELDVALUE FROM ADDEDFIELDS WHERE ID=" + dr["id"].ToString()); string pf = Q.Tables[0].Rows[0][0].ToString(); string pfv = Q.Tables[0].Rows[0][1].ToString(); if (pf.Length > 0) { IDataReader sqlDr = DatabaseConnection.CreateReader("SELECT " + pf + " FROM " + Enum.GetName(typeof(CRMTables), crmTables).ToUpper() + " WHERE ID=" + int.Parse(Session[(crmTables == CRMTables.Base_Companies)?"contact":"CurrentRefId"].ToString())); sqlDr.Read(); isParentCrossed = (sqlDr[0].ToString() == pfv); sqlDr.Close(); } if (isParentCrossed) { S.AppendFormat("<tr><td width=\"40%\">{0}</td>", dr["name"]); DataSet afCross = DatabaseConnection.CreateDataset("SELECT FIELDVAL FROM ADDEDFIELDS_CROSS WHERE IDRIF=" + dr["id"] + " AND ID=" + id); if (afCross.Tables[0].Rows.Count > 0) { S.AppendFormat("<td bgcolor=\"#FFFFFF\" class=\"VisForm\">{0} </td></tr>", afCross.Tables[0].Rows[0][0]); } else { S.Append("<td bgcolor=\"#FFFFFF\" class=\"VisForm\"> </td></tr>"); } afCross.Clear(); } } S.Append("</table>"); strOut = S.ToString(); } }
private void GetMap(CRMTables tableName) { switch (tableName) { case CRMTables.Base_Companies: if (ConfigSettings.SupportedLanguages.ToLower().IndexOf(UC.CultureSpecific.ToLower()) > -1) { importMap = String.Format("CompanyImportMap_{0}.xml", UC.CultureSpecific.ToLower()); } else { importMap = "CompanyImportMap_en.xml"; } break; case CRMTables.Base_Contacts: if (ConfigSettings.SupportedLanguages.ToLower().IndexOf(UC.CultureSpecific.ToLower()) > -1) { importMap = String.Format("ContactImportMap_{0}.xml", UC.CultureSpecific.ToLower()); } else { importMap = "ContactImportMap_en.xml"; } break; case CRMTables.CRM_Leads: if (ConfigSettings.SupportedLanguages.ToLower().IndexOf(UC.CultureSpecific.ToLower()) > -1) { importMap = String.Format("LeadImportMap_{0}.xml", UC.CultureSpecific.ToLower()); } else { importMap = "LeadImportMap_en.xml"; } break; case CRMTables.CRM_WorkActivity: if (ConfigSettings.SupportedLanguages.ToLower().IndexOf(UC.CultureSpecific.ToLower()) > -1) { importMap = String.Format("ActivityImportMap_{0}.xml", UC.CultureSpecific.ToLower()); } else { importMap = "ActivityImportMap_en.xml"; } break; } }
private void FillRepeaterFields(CRMTables table) { RepContacts.DataSource = DatabaseConnection.CreateDataset(String.Format("SELECT * FROM ADDEDFIELDS WHERE TABLENAME={0} ORDER BY VIEWORDER", (byte)table)); RepContacts.DataBind(); RepContacts.Visible = true; DataSet ds = DatabaseConnection.CreateDataset("SELECT * FROM ADDEDFIELD_DROPDOWN WHERE REFERENCETABLE=" + (byte)table); FieldRef.Items.Clear(); foreach (DataRow dr in ds.Tables[0].Rows) { ListItem li = new ListItem(); li.Text = Root.rm.GetString("SQLFree" + dr["rmValue"].ToString()); li.Value = dr["ID"].ToString(); FieldRef.Items.Add(li); } FieldRef.Items.Insert(0, Root.rm.GetString("SQLFree0")); FieldRef.Items[0].Value = "0"; }
public void FillFreeFields(int id, CRMTables crmTables, UserConfig UC) { string sqlStringQuery; sqlStringQuery = "SELECT * FROM ADDEDFIELDS WHERE TABLENAME=" + (byte)crmTables + " ORDER BY VIEWORDER"; DataSet ds = DatabaseConnection.CreateDataset(sqlStringQuery); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { try { if (Request.Form["Free_" + dr["name"]].Length > 0) { string sqlString; sqlString = "SELECT ID FROM ADDEDFIELDS_CROSS WHERE ID = " + id + " AND IDRIF=" + dr["id"]; using (DigiDapter dg = new DigiDapter(sqlString)) { dg.Add("ID", id); dg.Add("IDRIF", dr["id"]); dg.Add("FIELDVAL", Request.Form["Free_" + dr["name"]]); if (dg.HasRows) { dg.Execute("ADDEDFIELDS_CROSS", "ID = " + id + " AND IDRIF=" + dr["id"]); } else { dg.Execute("ADDEDFIELDS_CROSS", "PKEY = -1"); } } } else { DatabaseConnection.DoCommand("DELETE FROM ADDEDFIELDS_CROSS WHERE ID = " + id + " AND IDRIF=" + dr["id"]); } } catch { } } } }
public void SetFreeField(CRMTables table) { AddContactFields.Visible = false; switch (table) { case CRMTables.Base_Companies: Session["TableFreeField"] = "Base_Companies"; FillRepeaterFields(CRMTables.Base_Companies); break; case CRMTables.Base_Contacts: Session["TableFreeField"] = "Base_Contacts"; FillRepeaterFields(CRMTables.Base_Contacts); break; case CRMTables.CRM_Leads: Session["TableFreeField"] = "CRM_Leads"; FillRepeaterFields(CRMTables.CRM_Leads); break; } TabSwitch(); }
public string FreeFieldType(CRMTables crmTables, FreeFieldsType type, string name, int did, int id, string items) { StringBuilder sb = new StringBuilder(); string pf = String.Empty; string pfv = String.Empty; bool isParentCrossed = false; DataSet Q = DatabaseConnection.CreateDataset("SELECT PARENTFIELD,PARENTFIELDVALUE FROM ADDEDFIELDS WHERE ID=" + did); pf = Q.Tables[0].Rows[0][0].ToString(); pfv = Q.Tables[0].Rows[0][1].ToString(); if (pf.Length > 0 && id != -1) { IDataReader sqlDr = DatabaseConnection.CreateReader("SELECT " + pf + " FROM " + Enum.GetName(typeof(CRMTables), crmTables).ToUpper() + " WHERE ID=" + int.Parse(Session[(crmTables == CRMTables.Base_Companies) ? "contact" : "CurrentRefId"].ToString())); sqlDr.Read(); Trace.Warn("PF-PFV", pf + "-" + pfv); isParentCrossed = (sqlDr[0].ToString() == pfv); Trace.Warn("IsParentCrossed", isParentCrossed.ToString()); sqlDr.Close(); } if (pf.Length > 0) { if (isParentCrossed) { sb.AppendFormat("<tr ParentField=\"{1}\" ParentFieldValue=\"{2}\"><td width=\"40%\">{0}</td>", name, pf, pfv); } else { sb.AppendFormat("<tr ParentField=\"{1}\" ParentFieldValue=\"{2}\" style=\"display:none;\"><td width=\"40%\">{0}</td>", name, pf, pfv); } } else { sb.AppendFormat("<tr><td width=\"40%\">{0}</td>", name); } switch (type) { case FreeFieldsType.inputText: case FreeFieldsType.username: case FreeFieldsType.password: case FreeFieldsType.inputNumber: if (id != -1) { DataSet afCross = DatabaseConnection.CreateDataset("SELECT FIELDVAL FROM ADDEDFIELDS_CROSS WHERE IDRIF=" + did + " AND ID=" + id); if (afCross.Tables[0].Rows.Count > 0) { sb.AppendFormat("<td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" {2}class=\"BoxDesign\" value=\"{1}\"></td></tr>", name, afCross.Tables[0].Rows[0][0], (type == FreeFieldsType.inputNumber)?"onkeypress=\"NumbersOnly(event,'.,',this)\"":""); } else { sb.AppendFormat("<td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" {1}class=\"BoxDesign\"></td></tr>", name, (type == FreeFieldsType.inputNumber)?"onkeypress=\"NumbersOnly(event,'.,',this)\"":""); } afCross.Clear(); } else { sb.AppendFormat("<td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" {1}class=\"BoxDesign\"></td></tr>", name, (type == FreeFieldsType.inputNumber)?"onkeypress=\"NumbersOnly(event,'.,',this)\"":""); } break; case FreeFieldsType.inputDate: string imgBtn = string.Format("<td width=\"30\"> <img src=\"/i/SmallCalendar.gif\" border=0 style=\"cursor: pointer\" onclick=\"CreateBox('/Common/PopUpDate.aspx?Textbox=Free_{0}',event,195,195)\"></td>", name); if (id != -1) { DataSet afCross = DatabaseConnection.CreateDataset("SELECT FIELDVAL FROM ADDEDFIELDS_CROSS WHERE IDRIF=" + did + " AND ID=" + id); if (afCross.Tables[0].Rows.Count > 0) { sb.AppendFormat("<td><table width=\"100%\" cellspacing=0 cellpadding=0><tr><td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" onkeypress=\"DataCheck(this,event)\" MaxLength=\"10\" class=\"BoxDesign\" value=\"{1}\"></td>{2}</tr></table></td></tr>", name, afCross.Tables[0].Rows[0][0], imgBtn); } else { sb.AppendFormat("<td><table width=\"100%\" cellspacing=0 cellpadding=0><tr><td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" onkeypress=\"DataCheck(this,event)\" MaxLength=\"10\" class=\"BoxDesign\"></td>{1}</tr></table></td></tr>", name, imgBtn); } afCross.Clear(); } else { sb.AppendFormat("<td><table width=\"100%\" cellspacing=0 cellpadding=0><tr><td><input type=\"Text\" name=\"Free_{0}\" id=\"Free_{0}\" onkeypress=\"DataCheck(this,event)\" MaxLength=\"10\" class=\"BoxDesign\"></td>{1}</tr></table></td></tr>", name, imgBtn); } break; case FreeFieldsType.select: string[] it = items.Split('|'); DataSet afCrossS = DatabaseConnection.CreateDataset("SELECT FIELDVAL FROM ADDEDFIELDS_CROSS WHERE IDRIF=" + did + " AND ID=" + id); sb.AppendFormat("<td><select old=true name=\"Free_{0}\" id=\"Free_{0}\" class=\"BoxDesign\">", name); foreach (string op in it) { try { if (op == afCrossS.Tables[0].Rows[0][0].ToString()) { if (op.Length > 0) { sb.AppendFormat("<option selected>{0}</option>", op); } } else { if (op.Length > 0) { sb.AppendFormat("<option>{0}</option>", op); } } } catch { if (op.Length > 0) { sb.AppendFormat("<option>{0}</option>", op); } } } sb.Append("</select></td></tr>"); break; } return(sb.ToString()); }