/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CustomLosts GetModel(int CLID) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT CustomLosts.*, Customers.CusName"); strSql.Append(" FROM Customers INNER JOIN CustomLosts ON Customers.CusID = CustomLosts.CusID"); strSql.Append(" where CustomLosts.CLID=@CLID"); SqlParameter[] parameters = { new SqlParameter("@CLID", SqlDbType.Int, 4) }; parameters[0].Value = CLID; Maticsoft.Model.CustomLosts model = new Maticsoft.Model.CustomLosts(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateOne(Maticsoft.Model.CustomLosts model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CustomLosts set "); strSql.Append("CLEnterDate=@CLEnterDate,"); strSql.Append("CLReason=@CLReason,"); strSql.Append("CLState=@CLState"); strSql.Append(" where CLID=@CLID"); SqlParameter[] parameters = { new SqlParameter("@CLEnterDate", SqlDbType.DateTime), new SqlParameter("@CLReason", SqlDbType.NVarChar,500), new SqlParameter("@CLState", SqlDbType.Int, 4), new SqlParameter("@CLID", SqlDbType.Int, 4) }; parameters[0].Value = model.CLEnterDate; parameters[1].Value = model.CLReason; parameters[2].Value = model.CLState; parameters[3].Value = model.CLID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public int GetCount(Maticsoft.Model.CustomLosts models) { StringBuilder str = new StringBuilder(); if (!string.IsNullOrEmpty(models.CusName)) { str.AppendFormat(" and Customers.CusName like '%{0}%'", models.CusName); } if (models.CLState > 0) { str.AppendFormat(" and CustomLosts.CLState={0}", models.CLState); } if (!string.IsNullOrEmpty(Convert.ToString(models.CLEnterDate))) { var CLEnterDate = Convert.ToDateTime(models.CLEnterDate).ToString("yyyy-MM-dd"); str.AppendFormat(" and convert(varchar(10),CLEnterDate,120)='{0}' ", CLEnterDate); } return(new BLL.CustomLosts().GetRecordCountTwo("1>0" + str.ToString())); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CustomLosts DataRowToModel(DataRow row) { Maticsoft.Model.CustomLosts model = new Maticsoft.Model.CustomLosts(); if (row != null) { if (row["CLID"] != null && row["CLID"].ToString() != "") { model.CLID = int.Parse(row["CLID"].ToString()); } if (row["CusID"] != null) { model.CusID = row["CusID"].ToString(); } if (row["CLOrderDate"] != null && row["CLOrderDate"].ToString() != "") { model.CLOrderDate = DateTime.Parse(row["CLOrderDate"].ToString()); } if (row["CLDate"] != null && row["CLDate"].ToString() != "") { model.CLDate = DateTime.Parse(row["CLDate"].ToString()); } if (row["CLEnterDate"] != null && row["CLEnterDate"].ToString() != "") { model.CLEnterDate = DateTime.Parse(row["CLEnterDate"].ToString()); } if (row["CLReason"] != null) { model.CLReason = row["CLReason"].ToString(); } if (row["CLState"] != null && row["CLState"].ToString() != "") { model.CLState = int.Parse(row["CLState"].ToString()); } if (row["CusName"] != null) { model.CusName = row["CusName"].ToString(); } } return(model); }
//LostEnter.htm添加 public int ClostAdd(Maticsoft.Model.CustomLosts Clost) { Maticsoft.Model.CustomLosts list = new BLL.CustomLosts().GetModel(Clost.CLID); BLL.CustomLosts ClostBLL = new BLL.CustomLosts(); //修改客户状态为2 即流失 int success = 0; bool check2 = ClostBLL.ClostAdd(Clost);//修改流失措施表为确认流失 if (check2) { bool check = new BLL.Customers().UpdateOne(list.CusID); if (check) { success = 1; } else { success = 0; } } return(success); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.CustomLosts model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CustomLosts("); strSql.Append("CusID,CLOrderDate,CLDate,CLEnterDate,CLReason,CLState)"); strSql.Append(" values ("); strSql.Append("@CusID,@CLOrderDate,@CLDate,@CLEnterDate,@CLReason,@CLState)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CusID", SqlDbType.Char, 14), new SqlParameter("@CLOrderDate", SqlDbType.DateTime), new SqlParameter("@CLDate", SqlDbType.DateTime), new SqlParameter("@CLEnterDate", SqlDbType.DateTime), new SqlParameter("@CLReason", SqlDbType.NVarChar, 500), new SqlParameter("@CLState", SqlDbType.Int, 4) }; parameters[0].Value = model.CusID; parameters[1].Value = model.CLOrderDate; parameters[2].Value = model.CLDate; parameters[3].Value = model.CLEnterDate; parameters[4].Value = model.CLReason; parameters[5].Value = model.CLState; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
//显示数据 public List <Model.CustomLosts> SelectAllCustomLosts(int pagesize, int pageindex, Maticsoft.Model.CustomLosts models) { StringBuilder str = new StringBuilder(); if (!string.IsNullOrEmpty(models.CusName)) { str.AppendFormat(" and Customers.CusName like '%{0}%'", models.CusName); } if (models.CLState > 0) { str.AppendFormat(" and CustomLosts.CLState={0}", models.CLState); } if (!string.IsNullOrEmpty(Convert.ToString(models.CLEnterDate))) { var CLEnterDate = Convert.ToDateTime(models.CLEnterDate).ToString("yyyy-MM-dd"); str.AppendFormat(" and convert(varchar(10),CLEnterDate,120)='{0}' ", CLEnterDate); } BLL.CustomLosts CustomLosts = new BLL.CustomLosts(); return(CustomLosts.GetModelListTwo(str.ToString(), "1>0" + str.ToString(), pagesize, pageindex)); }