/// <summary> /// add data to database /// </summary> /// <param name="codeNum"></param> /// <returns></returns> public bool Add(string codeNum) { Hashtable SQLString = new Hashtable( ); StringBuilder strSql = new StringBuilder( ); ProductionErpEntity.BrakeBRAEntity _bra = new ProductionErpEntity.BrakeBRAEntity( ); ProductionErpEntity.BrakeBRBEntity _brb = new ProductionErpEntity.BrakeBRBEntity( ); _bra.BRA001 = _brb.BRB001 = codeNum; DataTable table = getWinBase(codeNum); if (table != null && table.Rows.Count > 0) { _bra.BRA002 = table.Rows [0] ["SRT003"].ToString( ); _bra.BRA003 = table.Rows [0] ["SRT004"].ToString( ); _bra.BRA004 = table.Rows [0] ["SRT005"].ToString( ); add_bra(SQLString, strSql, _bra); } else { return(false); } _brb.BRB003 = string.Empty; _brb.BRB004 = string.Empty; _brb.BRB005 = null; add_brb_para(SQLString, strSql, _brb); return(SqlHelper.ExecuteSqlTran(SQLString)); }
ProductionErpEntity.BrakeBRAEntity getModel(DataRow row) { ProductionErpEntity.BrakeBRAEntity _model = new ProductionErpEntity.BrakeBRAEntity( ); if (row != null) { if (row ["BRA001"] != null && row ["BRA001"].ToString( ) != string.Empty) { _model.BRA001 = row ["BRA001"].ToString( ); } if (row ["BRA002"] != null && row ["BRA002"].ToString( ) != string.Empty) { _model.BRA002 = row ["BRA002"].ToString( ); } if (row ["BRA003"] != null && row ["BRA003"].ToString( ) != string.Empty) { _model.BRA003 = row ["BRA003"].ToString( ); } if (row ["BRA004"] != null && row ["BRA004"].ToString( ) != string.Empty) { _model.BRA004 = row ["BRA004"].ToString( ); } } return(_model); }
public FormBrake( ) { InitializeComponent( ); _bra = new ProductionErpEntity.BrakeBRAEntity( ); _brb = new ProductionErpEntity.BrakeBRBEntity( ); _bll = new ProductionErpBll.Bll.BrakeBll( ); tableView = new DataTable( ); Utility.GridViewMoHuSelect.SetFilter(gridView1); FieldInfo fi = typeof(XPaint).GetField("graphics", BindingFlags.Static | BindingFlags.NonPublic); fi.SetValue(null, new DrawXPaint( )); barMenu.LinksPersistInfo.RemoveAt(toolExport.Id); barMenu.LinksPersistInfo.RemoveAt(toolDelete.Id); barMenu.LinksPersistInfo.RemoveAt(toolAdd.Id); wait.Hide( ); gridView1.OptionsBehavior.Editable = false; tableSup = _bll.getTableSup( ); editData.DataSource = tableSup; editData.DisplayMember = "BRB007"; editData.ValueMember = "BR"; tableSupOne = _bll.getTableSupOne( ); editOne.DataSource = tableSupOne; editOne.DisplayMember = "BRB007"; editOne.ValueMember = "BR"; }
void add_bra(Hashtable SQLString, StringBuilder strSql, ProductionErpEntity.BrakeBRAEntity _bra) { strSql = new StringBuilder( ); strSql.Append("INSERT INTO MOXBRA ("); strSql.Append("BRA001,BRA002,BRA003,BRA004) "); strSql.Append("VALUES ("); strSql.Append("@BRA001,@BRA002,@BRA003,@BRA004) "); SqlParameter [] parameter = { new SqlParameter("@BRA001", SqlDbType.NVarChar, 50), new SqlParameter("@BRA002", SqlDbType.NVarChar, 50), new SqlParameter("@BRA003", SqlDbType.NVarChar, 50), new SqlParameter("@BRA004", SqlDbType.NVarChar, 50) }; parameter [0].Value = _bra.BRA001; parameter [1].Value = _bra.BRA002; parameter [2].Value = _bra.BRA003; parameter [3].Value = _bra.BRA004; SQLString.Add(strSql, parameter); }
/// <summary> /// edit data to database /// </summary> /// <param name="table"></param> /// <returns></returns> public bool Save(DataTable table) { Hashtable SQLString = new Hashtable( ); StringBuilder strSql = new StringBuilder( ); ProductionErpEntity.BrakeBRAEntity _bra = new ProductionErpEntity.BrakeBRAEntity( ); ProductionErpEntity.BrakeBRBEntity _brb = new ProductionErpEntity.BrakeBRBEntity( ); for (int i = 0; i < table.Rows.Count; i++) { _brb.BRB001 = table.Rows [i] ["BRB001"].ToString( ); _brb.BRB002 = table.Rows [i] ["BRB002"].ToString( ); _brb.BRB003 = table.Rows [i] ["BRB003"].ToString( ); _brb.BRB004 = table.Rows [i] ["BRB004"].ToString( ); if (string.IsNullOrEmpty(table.Rows [i] ["BRB005"].ToString( ))) { _brb.BRB005 = null; } else { _brb.BRB005 = Convert.ToDateTime(table.Rows [i] ["BRB005"].ToString( )); } _brb.idx = string.IsNullOrEmpty(table.Rows [i] ["idx"].ToString( )) == true ? 0 : Convert.ToInt32(table.Rows [i] ["idx"].ToString( )); _brb.BRB007 = table.Rows [i] ["BRB007"].ToString( ); if (string.IsNullOrEmpty(table.Rows [i] ["BRB008"].ToString( ))) { _brb.BRB008 = null; } else { _brb.BRB008 = Convert.ToInt32(table.Rows [i] ["BRB008"].ToString( )); } if (Exists(_brb.idx)) { edit(SQLString, strSql, _brb); } } return(SqlHelper.ExecuteSqlTran(SQLString)); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { _bll.getCodeNum(_brb.BRB001); tableView = _bll.getTableView(_bra.BRA001); _bra = _bll.getModel(_bra.BRA001); }