private void Save_Param_Value(dynamic data, int cg_code, DBCRMTree db) { var s_param_value = JsonConvert.SerializeObject(data.param_value); List <CT_Param_Value> pvs = JsonConvert.DeserializeObject <List <CT_Param_Value> >(s_param_value); var o = new { PV_CG_Code = cg_code, PV_UType = (byte)UserSession.User.UG_UType, PV_AD_OM_Code = (int)UserSession.DealerEmpl.DE_AD_OM_Code }; db.Execute(@"DELETE FROM CT_Param_Value WHERE PV_CG_Code = @PV_CG_Code and PV_UType = @PV_UType and PV_AD_OM_Code = @PV_AD_OM_Code and PV_Type=1" , o); foreach (var pv in pvs) { pv.PV_CG_Code = o.PV_CG_Code; pv.PV_UType = o.PV_UType; pv.PV_AD_OM_Code = o.PV_AD_OM_Code; pv.Insert(); } }
private void Save_Param_Value_Method(string s_param_value, int cg_code, byte index, DBCRMTree db) { List <CT_Param_Value> pvs = JsonConvert.DeserializeObject <List <CT_Param_Value> >(s_param_value); var o = new { PV_CG_Code = cg_code, PV_UType = (byte)UserSession.User.UG_UType, PV_AD_OM_Code = (int)UserSession.DealerEmpl.DE_AD_OM_Code, PV_Contact_Index = index }; db.Execute(@"DELETE FROM CT_Param_Value WHERE PV_CG_Code = @PV_CG_Code and PV_Contact_Index=@PV_Contact_Index and PV_UType = @PV_UType and PV_AD_OM_Code = @PV_AD_OM_Code and PV_Type=2" , o); foreach (var pv in pvs) { pv.PV_Contact_Index = o.PV_Contact_Index; pv.PV_CG_Code = o.PV_CG_Code; pv.PV_UType = o.PV_UType; pv.PV_AD_OM_Code = o.PV_AD_OM_Code; pv.Insert(); } }
private void Save_Departments(dynamic data, DBCRMTree db) { var s_departments = JsonConvert.SerializeObject(data.departments.changes); List <CT_Dept_Name> departments = JsonConvert.DeserializeObject <List <CT_Dept_Name> >(s_departments); foreach (var pdn in departments) { pdn.PDN_AD_Code = UserSession.DealerEmpl.DE_AD_OM_Code; pdn.PDN_Update_dt = DateTime.Now; if (pdn.PDN_Code > 0) { pdn.Update(new string[] { "PDN_Name_EN", "PDN_Name_CN", "PDN_Update_dt" }); } else { pdn.PDN_Code = (short)pdn.Insert(); } if (null != pdn.EX_Values) { foreach (var v in pdn.EX_Values) { v.DV_PDN_Code = pdn.PDN_Code; v.DV_Update_dt = DateTime.Now; if (CT_Dept_Value.Exists("DV_PDN_Code = @DV_PDN_Code AND DV_PDV_Code = @DV_PDV_Code", v)) { db.Update <CT_Dept_Value>(@" SET DV_Value = @DV_Value, DV_Update_dt = @DV_Update_dt WHERE DV_PDN_Code = @DV_PDN_Code AND DV_PDV_Code = @DV_PDV_Code", v); } else { v.Insert(); } } } } var s_deletes = JsonConvert.SerializeObject(data.departments.deletes); List <CT_Dept_Name> deletes = JsonConvert.DeserializeObject <List <CT_Dept_Name> >(s_deletes); foreach (var d in deletes) { db.Execute("DELETE FROM CT_Dept_Values WHERE DV_PDN_Code = @0", d.PDN_Code); d.Delete(); } }
private void Save_SM_Values(dynamic data, int cg_code, DBCRMTree db) { var s_smvs = JsonConvert.SerializeObject(data.sm_values.changes); List <CT_SM_Value> smvs = JsonConvert.DeserializeObject <List <CT_SM_Value> >(s_smvs); db.Execute("DELETE FROM CT_SM_Values WHERE SMV_CG_Code = @0", cg_code); foreach (var smv in smvs) { smv.SMV_CG_Code = cg_code; smv.SMV_Type = 1;//1 campaign,2 events smv.Insert(); } }
private void Save_Camp_Methods(dynamic data, int cg_code, DBCRMTree db) { var s_campaign = JsonConvert.SerializeObject(data.campaign); CT_Campaign campaign = JsonConvert.DeserializeObject <CT_Campaign>(s_campaign); var s_smvs = JsonConvert.SerializeObject(data.camp_methods.changes); List <CT_Camp_Method> cms = JsonConvert.DeserializeObject <List <CT_Camp_Method> >(s_smvs); var file_guid = Guid.NewGuid().ToString(); byte index = 1; db.Execute("DELETE FROM CT_Camp_Methods WHERE CM_CG_Code = @0", cg_code); foreach (var cm in cms) { var CM_Filename = cm.CM_Filename; if (campaign.EX_T.HasValue && campaign.EX_T.Value == 1) { if (cm.CM_CG_Code > 0 && CM_Filename != cm.CM_Filename_Temp) { var fNames = CM_Filename.Split('.').ToList(); var extendName = "." + fNames[fNames.Count - 1]; cm.CM_Filename = file_guid + extendName; } } cm.CM_Contact_Index = index; cm.CM_CG_Code = cg_code; cm.Insert(); if (cm.EX_IsParamValue.HasValue && cm.EX_IsParamValue.Value && !string.IsNullOrWhiteSpace(cm.EX_ParamValue)) { Save_Param_Value_Method(cm.EX_ParamValue, cg_code, index, db); } Save_Camp_Files(CM_Filename, cm.CM_Filename_Temp, file_guid, campaign.EX_T); index++; } }