public void insert() { pbx = new model.pbxdatasourceDataContext(connectionString); pbx.Connection.Open(); for (int i = 0; i < 1000; i++) { model.CustomProperty customPro = new model.CustomProperty(); Random ran = new Random(); customPro.CustomId = ran.Next(19, 22); customPro.CustomLevel = ran.Next(0, 5).ToString(); customPro.CustomBuyCount = ran.Next(1000); customPro.CustomBuyAmount = ran.Next(1000000); customPro.CustomLoveBrand = "阿道夫" + i + "打" + i; customPro.CustomServiceComment = "好︿( ̄︶ ̄)︿︿( ̄︶ ̄)︿"; pbx.CustomProperty.InsertOnSubmit(customPro); } pbx.SubmitChanges(); }
/// <summary> /// 修改客户属性表 /// </summary> /// <param name="customPro">客户属性实体</param> /// <param name="mess"></param> /// <returns></returns> public bool UpdateCustomProperty(model.CustomProperty customPro, out string mess) { mess = ""; try { pbx = new model.pbxdatasourceDataContext(connectionString); pbx.Connection.Open(); var temp = from c in pbx.CustomProperty where customPro.CustomId == c.CustomId select c; if (temp.ToList().Count == 0)//判断改信息是否还存在 { foreach (var t in temp) { t.custom = customPro.custom; t.CustomBuyAmount = customPro.CustomBuyAmount; t.CustomBuyCount = customPro.CustomBuyCount; t.CustomId = customPro.CustomId; t.CustomLevel = customPro.CustomLevel; t.CustomLoveBrand = customPro.CustomLoveBrand; t.CustomServiceComment = customPro.CustomServiceComment; } } else { mess = "该信息已经不存在!"; return(false); } pbx.SubmitChanges(); return(true); } catch (Exception ex) { mess = ex.ToString(); return(false); } finally { pbx.Connection.Close(); } }
public bool InsertCustomProperty(model.CustomProperty customPro, out string mess) { mess = ""; try { pbx = new model.pbxdatasourceDataContext(connectionString); pbx.Connection.Open(); var temp = from c in pbx.CustomProperty where customPro.CustomId == c.CustomId select c; if (temp.ToList().Count > 0) { foreach (model.CustomProperty cus in temp) { cus.custom = customPro.custom; cus.CustomBuyAmount = customPro.CustomBuyAmount; cus.CustomBuyCount = customPro.CustomBuyCount; cus.CustomId = customPro.CustomId; cus.CustomLevel = customPro.CustomLevel; cus.CustomLoveBrand = customPro.CustomLoveBrand; cus.CustomServiceComment = customPro.CustomServiceComment; } } else { pbx.CustomProperty.InsertOnSubmit(customPro); } pbx.SubmitChanges(); return(true); } catch (Exception ex) { mess = ex.ToString(); return(false); } finally { pbx.Connection.Close(); } }
public bool InsertCustomProperty(model.CustomProperty customPro, out string mess) { return(dal.InsertCustomProperty(customPro, out mess)); }
/// <summary> /// 修改客户属性表 /// </summary> /// <param name="customPro">客户属性实体</param> /// <param name="mess"></param> /// <returns></returns> public bool UpdateCustomProperty(model.CustomProperty customPro, out string mess) { return(dal.UpdateCustomProperty(customPro, out mess)); }