/// <summary> /// 增加一条数据 /// </summary> public void Add(DTcms.Model.ReceivedMoney model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ReceivedMoney("); strSql.Append("Id,StoreInOrderId,CustomerId,Name,BeginChargingTime,EndChargingTime2,ChargingCount,TotalPrice,FactTotalPrice,CreateTime,Admin,Remark,Status"); strSql.Append(") values ("); strSql.Append("@Id,@StoreInOrderId,@CustomerId,@Name,@BeginChargingTime,@EndChargingTime2,@ChargingCount,@TotalPrice,@FactTotalPrice,@CreateTime,@Admin,@Remark,@Status"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@EndChargingTime2", SqlDbType.DateTime), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@FactTotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.StoreInOrderId; parameters[2].Value = model.CustomerId; parameters[3].Value = model.Name; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.EndChargingTime2; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.TotalPrice; parameters[8].Value = model.FactTotalPrice; parameters[9].Value = model.CreateTime; parameters[10].Value = model.Admin; parameters[11].Value = model.Remark; parameters[12].Value = model.Status; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.ReceivedMoney GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,StoreInOrderId,CustomerId,Name,EndChargingTime,BeginChargingTime,ReceivedTime,ChargingCount,TotalPrice,InvoicedPrice,CreateTime,Admin,Remark,Status,HasBeenInvoiced,InvoicedTime,InvoicedOperator,UnitPriceDetails from ReceivedMoney "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DTcms.Model.ReceivedMoney model = new DTcms.Model.ReceivedMoney(); 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 Update(DTcms.Model.ReceivedMoney model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ReceivedMoney set "); strSql.Append(" Id = @Id , "); strSql.Append(" StoreInOrderId = @StoreInOrderId , "); strSql.Append(" CustomerId = @CustomerId , "); strSql.Append(" Name = @Name , "); strSql.Append(" BeginChargingTime = @BeginChargingTime , "); strSql.Append(" EndChargingTime2 = @EndChargingTime2 , "); strSql.Append(" ChargingCount = @ChargingCount , "); strSql.Append(" TotalPrice = @TotalPrice , "); strSql.Append(" FactTotalPrice = @FactTotalPrice , "); strSql.Append(" CreateTime = @CreateTime , "); strSql.Append(" Admin = @Admin , "); strSql.Append(" Remark = @Remark , "); strSql.Append(" Status = @Status "); strSql.Append(" where Id=@Id and StoreInOrderId=@StoreInOrderId and CustomerId=@CustomerId "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@EndChargingTime2", SqlDbType.DateTime), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@FactTotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.StoreInOrderId; parameters[2].Value = model.CustomerId; parameters[3].Value = model.Name; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.EndChargingTime2; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.TotalPrice; parameters[8].Value = model.FactTotalPrice; parameters[9].Value = model.CreateTime; parameters[10].Value = model.Admin; parameters[11].Value = model.Remark; parameters[12].Value = model.Status; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.ReceivedMoney GetModel(int Id, int StoreInOrderId, int CustomerId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, StoreInOrderId, CustomerId, Name, BeginChargingTime, EndChargingTime2, ChargingCount, TotalPrice, FactTotalPrice, CreateTime, Admin, Remark, Status "); strSql.Append(" from ReceivedMoney "); strSql.Append(" where Id=@Id and StoreInOrderId=@StoreInOrderId and CustomerId=@CustomerId "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4) }; parameters[0].Value = Id; parameters[1].Value = StoreInOrderId; parameters[2].Value = CustomerId; DTcms.Model.ReceivedMoney model = new DTcms.Model.ReceivedMoney(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["StoreInOrderId"].ToString() != "") { model.StoreInOrderId = int.Parse(ds.Tables[0].Rows[0]["StoreInOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["CustomerId"].ToString() != "") { model.CustomerId = int.Parse(ds.Tables[0].Rows[0]["CustomerId"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["BeginChargingTime"].ToString() != "") { model.BeginChargingTime = DateTime.Parse(ds.Tables[0].Rows[0]["BeginChargingTime"].ToString()); } if (ds.Tables[0].Rows[0]["EndChargingTime2"].ToString() != "") { model.EndChargingTime2 = DateTime.Parse(ds.Tables[0].Rows[0]["EndChargingTime2"].ToString()); } if (ds.Tables[0].Rows[0]["ChargingCount"].ToString() != "") { model.ChargingCount = decimal.Parse(ds.Tables[0].Rows[0]["ChargingCount"].ToString()); } if (ds.Tables[0].Rows[0]["TotalPrice"].ToString() != "") { model.TotalPrice = decimal.Parse(ds.Tables[0].Rows[0]["TotalPrice"].ToString()); } if (ds.Tables[0].Rows[0]["FactTotalPrice"].ToString() != "") { model.FactTotalPrice = decimal.Parse(ds.Tables[0].Rows[0]["FactTotalPrice"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } model.Admin = ds.Tables[0].Rows[0]["Admin"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DTcms.Model.ReceivedMoney model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ReceivedMoney("); strSql.Append("StoreInOrderId,CustomerId,Name,EndChargingTime,BeginChargingTime,ReceivedTime,ChargingCount,TotalPrice,InvoicedPrice,CreateTime,Admin,Remark,Status,HasBeenInvoiced,InvoicedTime,InvoicedOperator,UnitPriceDetails)"); strSql.Append(" values ("); strSql.Append("@StoreInOrderId,@CustomerId,@Name,@EndChargingTime,@BeginChargingTime,@ReceivedTime,@ChargingCount,@TotalPrice,@InvoicedPrice,@CreateTime,@Admin,@Remark,@Status,@HasBeenInvoiced,@InvoicedTime,@InvoicedOperator,@UnitPriceDetails)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@EndChargingTime", SqlDbType.DateTime), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@ReceivedTime", SqlDbType.DateTime), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@InvoicedPrice", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@HasBeenInvoiced", SqlDbType.Bit, 1), new SqlParameter("@InvoicedTime", SqlDbType.DateTime), new SqlParameter("@InvoicedOperator", SqlDbType.VarChar, 254), new SqlParameter("@UnitPriceDetails", SqlDbType.VarChar, 1000) }; parameters[0].Value = model.StoreInOrderId; parameters[1].Value = model.CustomerId; parameters[2].Value = model.Name; parameters[3].Value = model.EndChargingTime; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.ReceivedTime; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.TotalPrice; parameters[8].Value = model.InvoicedPrice; parameters[9].Value = model.CreateTime; parameters[10].Value = model.Admin; parameters[11].Value = model.Remark; parameters[12].Value = model.Status; parameters[13].Value = model.HasBeenInvoiced; parameters[14].Value = model.InvoicedTime; parameters[15].Value = model.InvoicedOperator; parameters[16].Value = model.UnitPriceDetails; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务 model.Id = Convert.ToInt32(obj); new StoreInOrder().UpdateField(conn, trans, model.StoreInOrderId, "ChargingTime = '" + model.ReceivedTime + "'"); trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(model.Id > 0); }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.ReceivedMoney DataRowToModel(DataRow row) { DTcms.Model.ReceivedMoney model = new DTcms.Model.ReceivedMoney(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["StoreInOrderId"] != null && row["StoreInOrderId"].ToString() != "") { model.StoreInOrderId = int.Parse(row["StoreInOrderId"].ToString()); } if (row["CustomerId"] != null && row["CustomerId"].ToString() != "") { model.CustomerId = int.Parse(row["CustomerId"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["EndChargingTime"] != null && row["EndChargingTime"].ToString() != "") { model.EndChargingTime = DateTime.Parse(row["EndChargingTime"].ToString()); } if (row["BeginChargingTime"] != null && row["BeginChargingTime"].ToString() != "") { model.BeginChargingTime = DateTime.Parse(row["BeginChargingTime"].ToString()); } if (row["ReceivedTime"] != null && row["ReceivedTime"].ToString() != "") { model.ReceivedTime = DateTime.Parse(row["ReceivedTime"].ToString()); } if (row["ChargingCount"] != null && row["ChargingCount"].ToString() != "") { model.ChargingCount = decimal.Parse(row["ChargingCount"].ToString()); } if (row["TotalPrice"] != null && row["TotalPrice"].ToString() != "") { model.TotalPrice = decimal.Parse(row["TotalPrice"].ToString()); } if (row["InvoicedPrice"] != null && row["InvoicedPrice"].ToString() != "") { model.InvoicedPrice = decimal.Parse(row["InvoicedPrice"].ToString()); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["Admin"] != null) { model.Admin = row["Admin"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["HasBeenInvoiced"] != null && row["HasBeenInvoiced"].ToString() != "") { if ((row["HasBeenInvoiced"].ToString() == "1") || (row["HasBeenInvoiced"].ToString().ToLower() == "true")) { model.HasBeenInvoiced = true; } else { model.HasBeenInvoiced = false; } } if (row["InvoicedTime"] != null && row["InvoicedTime"].ToString() != "") { model.InvoicedTime = DateTime.Parse(row["InvoicedTime"].ToString()); } if (row["InvoicedOperator"] != null) { model.InvoicedOperator = row["InvoicedOperator"].ToString(); } if (row["UnitPriceDetails"] != null) { model.UnitPriceDetails = row["UnitPriceDetails"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.ReceivedMoney model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update ReceivedMoney set "); strSql.Append("StoreInOrderId=@StoreInOrderId,"); strSql.Append("CustomerId=@CustomerId,"); strSql.Append("Name=@Name,"); strSql.Append("EndChargingTime=@EndChargingTime,"); strSql.Append("BeginChargingTime=@BeginChargingTime,"); strSql.Append("ReceivedTime=@ReceivedTime,"); strSql.Append("ChargingCount=@ChargingCount,"); strSql.Append("TotalPrice=@TotalPrice,"); strSql.Append("InvoicedPrice=@InvoicedPrice,"); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("Admin=@Admin,"); strSql.Append("Remark=@Remark,"); strSql.Append("Status=@Status,"); strSql.Append("HasBeenInvoiced=@HasBeenInvoiced,"); strSql.Append("InvoicedTime=@InvoicedTime,"); strSql.Append("InvoicedOperator=@InvoicedOperator,"); strSql.Append("UnitPriceDetails=@UnitPriceDetails"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@EndChargingTime", SqlDbType.DateTime), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@ReceivedTime", SqlDbType.DateTime), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@InvoicedPrice", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@HasBeenInvoiced", SqlDbType.Bit, 1), new SqlParameter("@InvoicedTime", SqlDbType.DateTime), new SqlParameter("@InvoicedOperator", SqlDbType.VarChar, 254), new SqlParameter("@UnitPriceDetails", SqlDbType.VarChar, 1000), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.StoreInOrderId; parameters[1].Value = model.CustomerId; parameters[2].Value = model.Name; parameters[3].Value = model.EndChargingTime; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.ReceivedTime; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.TotalPrice; parameters[8].Value = model.InvoicedPrice; parameters[9].Value = model.CreateTime; parameters[10].Value = model.Admin; parameters[11].Value = model.Remark; parameters[12].Value = model.Status; parameters[13].Value = model.HasBeenInvoiced; parameters[14].Value = model.InvoicedTime; parameters[15].Value = model.InvoicedOperator; parameters[16].Value = model.UnitPriceDetails; parameters[17].Value = model.Id; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); new StoreInOrder().UpdateField(conn, trans, model.StoreInOrderId, "ChargingTime = '" + model.ReceivedTime + "'"); trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.ReceivedMoney DataRowToModel(DataRow row) { DTcms.Model.ReceivedMoney model = new DTcms.Model.ReceivedMoney(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["StoreInOrderId"] != null && row["StoreInOrderId"].ToString() != "") { model.StoreInOrderId = int.Parse(row["StoreInOrderId"].ToString()); } if (row["CustomerId"] != null && row["CustomerId"].ToString() != "") { model.CustomerId = int.Parse(row["CustomerId"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["EndChargingTime"] != null && row["EndChargingTime"].ToString() != "") { model.EndChargingTime = DateTime.Parse(row["EndChargingTime"].ToString()); } if (row["BeginChargingTime"] != null && row["BeginChargingTime"].ToString() != "") { model.BeginChargingTime = DateTime.Parse(row["BeginChargingTime"].ToString()); } if (row["ReceivedTime"] != null && row["ReceivedTime"].ToString() != "") { model.ReceivedTime = DateTime.Parse(row["ReceivedTime"].ToString()); } if (row["ChargingCount"] != null && row["ChargingCount"].ToString() != "") { model.ChargingCount = decimal.Parse(row["ChargingCount"].ToString()); } if (row["TotalPrice"] != null && row["TotalPrice"].ToString() != "") { model.TotalPrice = decimal.Parse(row["TotalPrice"].ToString()); } if (row["InvoicedPrice"] != null && row["InvoicedPrice"].ToString() != "") { model.InvoicedPrice = decimal.Parse(row["InvoicedPrice"].ToString()); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["Admin"] != null) { model.Admin = row["Admin"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["HasBeenInvoiced"] != null && row["HasBeenInvoiced"].ToString() != "") { if ((row["HasBeenInvoiced"].ToString() == "1") || (row["HasBeenInvoiced"].ToString().ToLower() == "true")) { model.HasBeenInvoiced = true; } else { model.HasBeenInvoiced = false; } } if (row["InvoicedTime"] != null && row["InvoicedTime"].ToString() != "") { model.InvoicedTime = DateTime.Parse(row["InvoicedTime"].ToString()); } if (row["InvoicedOperator"] != null) { model.InvoicedOperator = row["InvoicedOperator"].ToString(); } if (row["UnitPriceDetails"] != null) { model.UnitPriceDetails = row["UnitPriceDetails"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.ReceivedMoney GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,StoreInOrderId,CustomerId,Name,EndChargingTime,BeginChargingTime,ReceivedTime,ChargingCount,TotalPrice,InvoicedPrice,CreateTime,Admin,Remark,Status,HasBeenInvoiced,InvoicedTime,InvoicedOperator,UnitPriceDetails from ReceivedMoney "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; DTcms.Model.ReceivedMoney model = new DTcms.Model.ReceivedMoney(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }