/// <summary> /// 添加供应商档案的sql语句 /// </summary> /// <param name="listSql"></param> /// <param name="partID"></param> private void AddWareHouseSqlString(List <SysSQLString> listSql, string whId) { SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary <string, string> dicParam = new Dictionary <string, string>();//参数 tb_warehouse model = new tb_warehouse(); CommonFuncCall.SetModelObjectValue(this, model); model.wh_id = whId; int datasorces = (int)SYSModel.DataSources.EnumDataSources.SELFBUILD;//1自建,2宇通 model.data_source = datasorces.ToString(); int StatusNum = (int)SYSModel.DataSources.EnumStatus.Start;//0停用,1启用 model.status = StatusNum.ToString(); model.enable_flag = "1"; model.create_by = GlobalStaticObj.UserID; model.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now); model.com_id = txtChooseCompanty.Tag == null ? "" : txtChooseCompanty.Tag.ToString(); model.wh_head = txtChooseWhHead.Text; if (model != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_warehouse( "); StringBuilder sp = new StringBuilder(); StringBuilder sb_prame = new StringBuilder(); foreach (PropertyInfo info in model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(model, null); sb_prame.Append("," + name); sp.Append(",@" + name); dicParam.Add(name, value == null ? "" : value.ToString()); } sb.Append(sb_prame.ToString().Substring(1, sb_prame.ToString().Length - 1) + ") Values ("); sb.Append(sp.ToString().Substring(1, sp.ToString().Length - 1) + ")").Append(";"); sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } }
/// <summary> /// 编辑供应商档案的sql语句 /// </summary> /// <param name="listSql"></param> /// <param name="supID"></param> /// <param name="model"></param> private void EditWareHouseSqlString(List <SysSQLString> listSql, string whId, tb_warehouse model) { SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary <string, string> dicParam = new Dictionary <string, string>();//参数 CommonFuncCall.SetModelObjectValue(this, model); model.update_by = GlobalStaticObj.UserID; model.update_time = Common.LocalDateTimeToUtcLong(DateTime.Now); model.com_id = txtChooseCompanty.Tag == null ? "" : txtChooseCompanty.Tag.ToString(); model.wh_head = txtChooseWhHead.Text; if (model != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Update tb_warehouse Set "); bool isFirstValue = true; foreach (PropertyInfo info in model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(model, null); if (isFirstValue) { isFirstValue = false; sb.Append(name); sb.Append("="); sb.Append("@" + name); } else { sb.Append("," + name); sb.Append("="); sb.Append("@" + name); } dicParam.Add(name, value == null ? "" : value.ToString()); } sb.Append(" where wh_id='" + whId + "';"); sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } }