void AddBody(Hashtable SQLString, MulaolaoLibrary.SanitationCheckBodyEntity model) { StringBuilder strSql = new StringBuilder( ); strSql.Append("insert into R_SAD("); strSql.Append("SAD001,SAD002,SAD003,SAD004,SAD005,SAD006,SAD007,SAD008,SAD009)"); strSql.Append(" values ("); strSql.Append("@SAD001,@SAD002,@SAD003,@SAD004,@SAD005,@SAD006,@SAD007,@SAD008,@SAD009)"); SqlParameter [] parameters = { new SqlParameter("@SAD001", SqlDbType.NVarChar, 20), new SqlParameter("@SAD002", SqlDbType.NVarChar, 20), new SqlParameter("@SAD003", SqlDbType.NVarChar, 100), new SqlParameter("@SAD004", SqlDbType.NVarChar, 255), new SqlParameter("@SAD005", SqlDbType.Int, 4), new SqlParameter("@SAD006", SqlDbType.Int, 4), new SqlParameter("@SAD007", SqlDbType.NVarChar, 20), new SqlParameter("@SAD008", SqlDbType.NVarChar, 20), new SqlParameter("@SAD009", SqlDbType.NVarChar, 255) }; parameters [0].Value = model.SAD001; parameters [1].Value = model.SAD002; parameters [2].Value = model.SAD003; parameters [3].Value = model.SAD004; parameters [4].Value = model.SAD005; parameters [5].Value = model.SAD006; parameters [6].Value = model.SAD007; parameters [7].Value = model.SAD008; parameters [8].Value = model.SAD009; SQLString.Add(strSql, parameters); }
public FormSanitationCheck( ) { InitializeComponent( ); header = new MulaolaoLibrary.SanitationCheckHeaderEntity( ); body = new MulaolaoLibrary.SanitationCheckBodyEntity( ); _bll = new MulaolaoBll.Bll.SanitationCheckBll( ); GridViewMoHuSelect.SetFilter(new DevExpress.XtraGrid.Views.Grid.GridView [] { gridView1, View1, View2 }); GrivColumnStyle.setColumnStyle(new DevExpress.XtraGrid.Views.Grid.GridView [] { gridView1, View1, View2 }); toolStrip1.Items.Remove(toolReview); toolStrip1.Items.Remove(toolMaintain); toolStrip1.Items.Remove(toolLibrary); toolStrip1.Items.Remove(toolStorage); toolStrip1.Items.Remove(toolcopy); controlClear( ); controlUnEnable( ); Edit1.DataSource = _bll.getTableWork( ); Edit1.DisplayMember = "DAA002"; Edit1.ValueMember = "DAA002"; Edit2.DataSource = _bll.getTableGroup( ); Edit2.DisplayMember = "DAA002"; Edit2.ValueMember = "DAA002"; }
/// <summary> /// 编辑数据 /// </summary> /// <param name="model"></param> /// <param name="table"></param> /// <param name="idxList"></param> /// <returns></returns> public bool Edit(MulaolaoLibrary.SanitationCheckHeaderEntity model, DataTable table, List <string> idxList) { Hashtable SQLString = new Hashtable( ); EditHeader(SQLString, model); MulaolaoLibrary.SanitationCheckBodyEntity entity = new MulaolaoLibrary.SanitationCheckBodyEntity( ); entity.SAD001 = model.SAC001; foreach (DataRow row in table.Rows) { entity.idx = string.IsNullOrEmpty(row ["idx"].ToString( )) == true ? 0 : Convert.ToInt32(row ["idx"]); entity.SAD002 = row ["SAD002"].ToString( ); entity.SAD003 = row ["SAD003"].ToString( ); entity.SAD004 = row ["SAD004"].ToString( ); if (row ["SAD005"] == null || row ["SAD005"].ToString( ) == string.Empty) { entity.SAD005 = null; } else { entity.SAD005 = Convert.ToInt32(row ["SAD005"].ToString( )); } if (row ["SAD006"] == null || row ["SAD006"].ToString( ) == string.Empty) { entity.SAD006 = null; } else { entity.SAD006 = Convert.ToInt32(row ["SAD006"].ToString( )); } entity.SAD007 = row ["SAD007"].ToString( ); entity.SAD008 = row ["SAD008"].ToString( ); entity.SAD009 = row ["SAD009"].ToString( ); //if ( row [ "SAD019" ] == null || row [ "SAD019" ] . ToString ( ) == string . Empty ) // entity . SAD019 = null; //else // entity . SAD019 = ( byte? [ ] ) ( row [ "SAD019" ] ); if (entity.idx > 0) { EditBody(SQLString, entity); } else { AddBody(SQLString, entity); } } foreach (string s in idxList) { DeleteBody(SQLString, s); } return(SqlHelper.ExecuteSqlTran(SQLString)); }
/// <summary> /// 保存数据 /// </summary> /// <param name="model"></param> /// <param name="table"></param> /// <returns></returns> public bool Save(MulaolaoLibrary.SanitationCheckHeaderEntity model, DataTable table) { Hashtable SQLString = new Hashtable( ); model.SAC001 = getCode( ); AddHeader(SQLString, model); MulaolaoLibrary.SanitationCheckBodyEntity entity = new MulaolaoLibrary.SanitationCheckBodyEntity( ); entity.SAD001 = model.SAC001; foreach (DataRow row in table.Rows) { entity.SAD002 = row ["SAD002"].ToString( ); entity.SAD003 = row ["SAD003"].ToString( ); entity.SAD004 = row ["SAD004"].ToString( ); if (row ["SAD005"] == null || row ["SAD005"].ToString( ) == string.Empty) { entity.SAD005 = null; } else { entity.SAD005 = Convert.ToInt32(row ["SAD005"].ToString( )); } if (row ["SAD006"] == null || row ["SAD006"].ToString( ) == string.Empty) { entity.SAD006 = null; } else { entity.SAD006 = Convert.ToInt32(row ["SAD006"].ToString( )); } entity.SAD007 = row ["SAD007"].ToString( ); entity.SAD008 = row ["SAD008"].ToString( ); entity.SAD009 = row ["SAD009"].ToString( ); //if ( row [ "SAD019" ] == null || row [ "SAD019" ] . ToString ( ) == string . Empty ) // entity . SAD019 = null; //else // entity . SAD019 = ( byte? [ ] ) ( row [ "SAD019" ] ); AddBody(SQLString, entity); } return(SqlHelper.ExecuteSqlTran(SQLString)); }
void EditBody(Hashtable SQLString, MulaolaoLibrary.SanitationCheckBodyEntity model) { StringBuilder strSql = new StringBuilder( ); strSql.Append("update R_SAD set "); strSql.Append("SAD002=@SAD002,"); strSql.Append("SAD003=@SAD003,"); strSql.Append("SAD004=@SAD004,"); strSql.Append("SAD005=@SAD005,"); strSql.Append("SAD006=@SAD006,"); strSql.Append("SAD007=@SAD007,"); strSql.Append("SAD008=@SAD008,"); strSql.Append("SAD009=@SAD009"); strSql.Append(" where idx=@idx"); SqlParameter [] parameters = { new SqlParameter("@SAD002", SqlDbType.NVarChar, 20), new SqlParameter("@SAD003", SqlDbType.NVarChar, 100), new SqlParameter("@SAD004", SqlDbType.NVarChar, 255), new SqlParameter("@SAD005", SqlDbType.Int, 4), new SqlParameter("@SAD006", SqlDbType.Int, 4), new SqlParameter("@SAD007", SqlDbType.NVarChar, 20), new SqlParameter("@SAD008", SqlDbType.NVarChar, 20), new SqlParameter("@SAD009", SqlDbType.NVarChar, 255), new SqlParameter("@idx", SqlDbType.Int, 4) }; parameters [0].Value = model.SAD002; parameters [1].Value = model.SAD003; parameters [2].Value = model.SAD004; parameters [3].Value = model.SAD005; parameters [4].Value = model.SAD006; parameters [5].Value = model.SAD007; parameters [6].Value = model.SAD008; parameters [7].Value = model.SAD009; parameters [8].Value = model.idx; SQLString.Add(strSql, parameters); }