public bool Update(AccounModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update Fund_Prj_Accoun set "); builder.Append("PrjGuid=@PrjGuid,"); builder.Append("accountNum=@accountNum,"); builder.Append("acountName=@acountName,"); builder.Append("Remark=@Remark,"); builder.Append("initialFund=@initialFund "); builder.Append(" where AccountID=@AccountID "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@PrjGuid", model.PrjGuid), new SqlParameter("@accountNum", model.accountNum), new SqlParameter("@acountName", model.acountName), new SqlParameter("@Remark", model.Remark), new SqlParameter("@initialFund", model.initialFund), new SqlParameter("@AccountID", model.AccountID) }; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters) > 0); }
public int Add(AccounModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Fund_Prj_Accoun("); builder.Append("AccountID,PrjGuid,accountNum,acountName,"); builder.Append("creatDate,createMan,authorizer,Remark,initialFund,"); builder.Append("AccountState,FlowState"); builder.Append(")"); builder.Append(" values ("); builder.Append("@AccountID,@PrjGuid,@accountNum,"); builder.Append("@acountName,@creatDate,@createMan,"); builder.Append("@authorizer,@Remark,@initialFund, '0', '-1'"); builder.Append(")"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@AccountID", model.AccountID), new SqlParameter("@PrjGuid", model.PrjGuid), new SqlParameter("@accountNum", model.accountNum), new SqlParameter("@acountName", model.acountName), new SqlParameter("@creatDate", model.creatDate), new SqlParameter("@createMan", model.createMan), new SqlParameter("@authorizer", model.authorizer), new SqlParameter("@Remark", model.Remark), new SqlParameter("@initialFund", model.initialFund) }; object obj2 = SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters); if (obj2 == null) { return(0); } return(Convert.ToInt32(obj2)); }
public AccounModel GetModel(string AccountID) { StringBuilder builder = new StringBuilder(); builder.Append("select top 1 AccountID,PrjGuid,accountNum,acountName"); builder.Append(",creatDate,createMan,activeDate,activeMan,authorizer,"); builder.Append("closeDate,closeMan,Remark,initialFund,AccountState,"); builder.Append("FlowState,moneyRate,IncomeFund,PayoutFund,CurrentFund from Fund_Prj_Accoun "); builder.Append(" where AccountID=@AccountID "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@AccountID", AccountID) }; AccounModel model = new AccounModel(); DataTable table = SqlHelper.ExecuteQuery(CommandType.Text, builder.ToString(), commandParameters); if (table.Rows.Count <= 0) { return(null); } if ((table.Rows[0]["AccountID"] != null) && (table.Rows[0]["AccountID"].ToString() != "")) { model.AccountID = new Guid(table.Rows[0]["AccountID"].ToString()); } if ((table.Rows[0]["PrjGuid"] != null) && (table.Rows[0]["PrjGuid"].ToString() != "")) { model.PrjGuid = table.Rows[0]["PrjGuid"].ToString(); } if ((table.Rows[0]["accountNum"] != null) && (table.Rows[0]["accountNum"].ToString() != "")) { model.accountNum = table.Rows[0]["accountNum"].ToString(); } if ((table.Rows[0]["acountName"] != null) && (table.Rows[0]["acountName"].ToString() != "")) { model.acountName = table.Rows[0]["acountName"].ToString(); } if ((table.Rows[0]["creatDate"] != null) && (table.Rows[0]["creatDate"].ToString() != "")) { model.creatDate = new DateTime?(DateTime.Parse(table.Rows[0]["creatDate"].ToString())); } if ((table.Rows[0]["createMan"] != null) && (table.Rows[0]["createMan"].ToString() != "")) { model.createMan = table.Rows[0]["createMan"].ToString(); } if ((table.Rows[0]["activeDate"] != null) && (table.Rows[0]["activeDate"].ToString() != "")) { model.activeDate = new DateTime?(DateTime.Parse(table.Rows[0]["activeDate"].ToString())); } if ((table.Rows[0]["activeMan"] != null) && (table.Rows[0]["activeMan"].ToString() != "")) { model.activeMan = table.Rows[0]["activeMan"].ToString(); } if ((table.Rows[0]["authorizer"] != null) && (table.Rows[0]["authorizer"].ToString() != "")) { model.authorizer = table.Rows[0]["authorizer"].ToString(); } if ((table.Rows[0]["closeDate"] != null) && (table.Rows[0]["closeDate"].ToString() != "")) { model.closeDate = new DateTime?(DateTime.Parse(table.Rows[0]["closeDate"].ToString())); } if ((table.Rows[0]["closeMan"] != null) && (table.Rows[0]["closeMan"].ToString() != "")) { model.closeMan = table.Rows[0]["closeMan"].ToString(); } if ((table.Rows[0]["Remark"] != null) && (table.Rows[0]["Remark"].ToString() != "")) { model.Remark = table.Rows[0]["Remark"].ToString(); } if ((table.Rows[0]["initialFund"] != null) && (table.Rows[0]["initialFund"].ToString() != "")) { model.initialFund = new decimal?(decimal.Parse(table.Rows[0]["initialFund"].ToString())); } if ((table.Rows[0]["AccountState"] != null) && (table.Rows[0]["AccountState"].ToString() != "")) { model.AccountState = new int?(int.Parse(table.Rows[0]["AccountState"].ToString())); } if ((table.Rows[0]["FlowState"] != null) && (table.Rows[0]["FlowState"].ToString() != "")) { model.FlowState = new int?(int.Parse(table.Rows[0]["FlowState"].ToString())); } if ((table.Rows[0]["moneyRate"] != null) && (table.Rows[0]["moneyRate"].ToString() != "")) { model.moneyRate = new decimal?(decimal.Parse(table.Rows[0]["moneyRate"].ToString())); } if ((table.Rows[0]["IncomeFund"] != null) && (table.Rows[0]["IncomeFund"].ToString() != "")) { model.IncomeFund = new decimal?(decimal.Parse(table.Rows[0]["IncomeFund"].ToString())); } if ((table.Rows[0]["PayoutFund"] != null) && (table.Rows[0]["PayoutFund"].ToString() != "")) { model.PayoutFund = new decimal?(decimal.Parse(table.Rows[0]["PayoutFund"].ToString())); } if ((table.Rows[0]["CurrentFund"] != null) && (table.Rows[0]["CurrentFund"].ToString() != "")) { model.CurrentFund = new decimal?(decimal.Parse(table.Rows[0]["CurrentFund"].ToString())); } return(model); }