private int _Insert(MaterialOutDtlModel mObj) { int materialOutDtlCode; try { StringBuilder builder = new StringBuilder(); builder.Append("insert into MaterialOutDtl("); builder.Append("MaterialOutDtlCode,MaterialOutCode,MaterialCode,MaterialInDtlCode,OutQty,OutPrice,OutMoney)"); builder.Append(" values ("); builder.Append("@MaterialOutDtlCode,@MaterialOutCode,@MaterialCode,@MaterialInDtlCode,@OutQty,@OutPrice,@OutMoney) "); this._DataProcess.CommandText = builder.ToString(); this._DataProcess.ProcessParametersAdd("@MaterialOutDtlCode", SqlDbType.Int, 4, mObj.MaterialOutDtlCode); this._DataProcess.ProcessParametersAdd("@MaterialOutCode", SqlDbType.Int, 4, mObj.MaterialOutCode); this._DataProcess.ProcessParametersAdd("@MaterialCode", SqlDbType.Int, 4, (mObj.MaterialCode == 0) ? null : mObj.MaterialCode.ToString()); this._DataProcess.ProcessParametersAdd("@MaterialInDtlCode", SqlDbType.Int, 4, (mObj.MaterialInDtlCode == 0) ? null : mObj.MaterialInDtlCode.ToString()); this._DataProcess.ProcessParametersAdd("@OutQty", SqlDbType.Decimal, 9, mObj.OutQty); this._DataProcess.ProcessParametersAdd("@OutPrice", SqlDbType.Decimal, 9, mObj.OutPrice); this._DataProcess.ProcessParametersAdd("@OutMoney", SqlDbType.Decimal, 9, mObj.OutMoney); this._DataProcess.RunSql(); materialOutDtlCode = mObj.MaterialOutDtlCode; } catch (Exception exception) { throw exception; } return(materialOutDtlCode); }
/// <summary> /// 新增明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAddDtl_ServerClick(object sender, EventArgs e) { List <MaterialOutDtlModel> Models = GetScreenDtl(); MaterialOutDtlModel mObj = new MaterialOutDtlModel(); Models.Add(mObj); BindDtl(Models); }
private List <MaterialOutDtlModel> _Select(MaterialOutDtlQueryModel qmObj) { List <MaterialOutDtlModel> list2; try { List <MaterialOutDtlModel> list = new List <MaterialOutDtlModel>(); StringBuilder builder = new StringBuilder(); builder.Append("select * from V_MaterialOutDtl as MaterialOutDtl "); builder.Append(qmObj.QueryConditionStr); if ((qmObj.SortColumns == null) || (qmObj.SortColumns.Length == 0)) { builder.Append(" ORDER BY MaterialOutDtlCode desc"); } else { builder.Append(" ORDER BY " + qmObj.SortColumns); } this._DataProcess.CommandText = builder.ToString(); this._DataProcess.SqlParameters = qmObj.Parameters; SqlDataReader sqlDataReader = null; int num = 0; try { sqlDataReader = this._DataProcess.GetSqlDataReader(); while (sqlDataReader.Read()) { if ((num >= qmObj.StartRecord) && ((list.Count < qmObj.MaxRecords) || (qmObj.MaxRecords == -1))) { MaterialOutDtlModel model = new MaterialOutDtlModel(); this.Initialize(sqlDataReader, model); list.Add(model); } num++; } } catch (Exception exception) { throw exception; } finally { if (sqlDataReader != null) { sqlDataReader.Close(); } } list2 = list; } catch (Exception exception2) { throw exception2; } return(list2); }
public int Delete(MaterialOutDtlModel ObjModel, SqlTransaction Transaction) { int num; try { num = this.Delete(ObjModel.MaterialOutDtlCode, Transaction); } catch (Exception exception) { throw exception; } return(num); }
public int Update(MaterialOutDtlModel ObjModel, SqlTransaction Transaction) { int num; try { num = new MaterialOutDtlDAL(Transaction).Update(ObjModel); } catch (Exception exception) { throw exception; } return(num); }
public int Update(MaterialOutDtlModel mObj) { int num; try { num = this._Update(mObj); } catch (Exception exception) { throw exception; } return(num); }
public int Delete(MaterialOutDtlModel mObj) { int num; try { num = this._Delete(mObj.MaterialOutDtlCode); } catch (Exception exception) { throw exception; } return(num); }
private int _Update(MaterialOutDtlModel mObj) { int num; try { StringBuilder builder = new StringBuilder(); builder.Append("update MaterialOutDtl set "); if (mObj.MaterialOutCode != 0) { builder.Append("MaterialOutCode=@MaterialOutCode,"); this._DataProcess.ProcessParametersAdd("@MaterialOutCode", SqlDbType.Int, 4, mObj.MaterialOutCode); } if (mObj.MaterialCode != 0) { builder.Append("MaterialCode=@MaterialCode,"); this._DataProcess.ProcessParametersAdd("@MaterialCode", SqlDbType.Int, 4, mObj.MaterialCode); } if (mObj.MaterialInDtlCode != 0) { builder.Append("MaterialInDtlCode=@MaterialInDtlCode,"); this._DataProcess.ProcessParametersAdd("@MaterialInDtlCode", SqlDbType.Int, 4, mObj.MaterialInDtlCode); } if (mObj.OutQty != 0M) { builder.Append("OutQty=@OutQty,"); this._DataProcess.ProcessParametersAdd("@OutQty", SqlDbType.Decimal, 9, mObj.OutQty); } if (mObj.OutPrice != 0M) { builder.Append("OutPrice=@OutPrice,"); this._DataProcess.ProcessParametersAdd("@OutPrice", SqlDbType.Decimal, 9, mObj.OutPrice); } if (mObj.OutMoney != 0M) { builder.Append("OutMoney=@OutMoney,"); this._DataProcess.ProcessParametersAdd("@OutMoney", SqlDbType.Decimal, 9, mObj.OutMoney); } builder.Remove(builder.Length - 1, 1); builder.Append(" where MaterialOutDtlCode=@MaterialOutDtlCode"); this._DataProcess.ProcessParametersAdd("@MaterialOutDtlCode", SqlDbType.Int, 4, mObj.MaterialOutDtlCode); this._DataProcess.CommandText = builder.ToString(); num = this._DataProcess.RunSql(); } catch (Exception exception) { throw exception; } return(num); }
private MaterialOutDtlModel _DataBind(int Code) { MaterialOutDtlModel model2; try { MaterialOutDtlModel model = new MaterialOutDtlModel(); StringBuilder builder = new StringBuilder(); builder.Append("select * from V_MaterialOutDtl as MaterialOutDtl "); builder.Append(" where MaterialOutDtlCode=@MaterialOutDtlCode"); this._DataProcess.CommandText = builder.ToString(); this._DataProcess.ProcessParametersAdd("@MaterialOutDtlCode", SqlDbType.Int, 4, Code); SqlDataReader sqlDataReader = null; try { sqlDataReader = this._DataProcess.GetSqlDataReader(); while (sqlDataReader.Read()) { this.Initialize(sqlDataReader, model); } } catch (Exception exception) { throw exception; } finally { if (sqlDataReader != null) { sqlDataReader.Close(); } } model2 = model; } catch (Exception exception2) { throw exception2; } return(model2); }
/// <summary> /// 取屏幕明细的List /// </summary> /// <returns></returns> private List <MaterialOutDtlModel> GetScreenDtl() { DataGrid dgDtl = (DataGrid)this.FormView1.Row.FindControl("dgDtl"); List <MaterialOutDtlModel> Models = (List <MaterialOutDtlModel>)ViewState["Models"]; int i = -1; foreach (DataGridItem item in dgDtl.Items) { i++; string DtlCode = dgDtl.DataKeys[i].ToString(); MaterialOutDtlModel mObj = Models[i]; mObj.OutQty = RmsPM.BLL.ConvertRule.ToDecimal(((WebNumericEdit)item.FindControl("txtOutQty")).ValueDecimal); mObj.OutPrice = RmsPM.BLL.ConvertRule.ToDecimal(((RmsPM.Web.UserControls.InputMaterialin)item.FindControl("InputMaterialin")).OutPrice); mObj.MaterialCode = RmsPM.BLL.ConvertRule.ToInt(((RmsPM.Web.UserControls.InputMaterialin)item.FindControl("InputMaterialin")).MaterialCode); mObj.MaterialInDtlCode = RmsPM.BLL.ConvertRule.ToInt(((RmsPM.Web.UserControls.InputMaterialin)item.FindControl("InputMaterialin")).MaterialInDtlCode); mObj.OutMoney = Math.Round(RmsPM.BLL.ConvertRule.ToDecimal((double)mObj.OutQty * (double)mObj.OutPrice), 2); } return(Models); }
private void Initialize(SqlDataReader reader, MaterialOutDtlModel obj) { try { if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutDtlCode")) != DBNull.Value) { obj.MaterialOutDtlCode = reader.GetInt32(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutDtlCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutCode")) != DBNull.Value) { obj.MaterialOutCode = reader.GetInt32(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialCode")) != DBNull.Value) { obj.MaterialCode = reader.GetInt32(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInDtlCode")) != DBNull.Value) { obj.MaterialInDtlCode = reader.GetInt32(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInDtlCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutQty")) != DBNull.Value) { obj.OutQty = reader.GetDecimal(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutQty")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutPrice")) != DBNull.Value) { obj.OutPrice = reader.GetDecimal(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutPrice")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutMoney")) != DBNull.Value) { obj.OutMoney = reader.GetDecimal(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutMoney")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialName")) != DBNull.Value) { obj.MaterialName = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialName")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "Spec")) != DBNull.Value) { obj.Spec = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "Spec")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "Unit")) != DBNull.Value) { obj.Unit = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "Unit")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupCode")) != DBNull.Value) { obj.GroupCode = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupName")) != DBNull.Value) { obj.GroupName = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupName")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupFullID")) != DBNull.Value) { obj.GroupFullID = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupFullID")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupSortID")) != DBNull.Value) { obj.GroupSortID = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "GroupSortID")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutID")) != DBNull.Value) { obj.MaterialOutID = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialOutID")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutDate")) != DBNull.Value) { obj.OutDate = reader.GetDateTime(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "OutDate")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "ContractCode")) != DBNull.Value) { obj.ContractCode = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "ContractCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInCode")) != DBNull.Value) { obj.MaterialInCode = reader.GetInt32(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInID")) != DBNull.Value) { obj.MaterialInID = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "MaterialInID")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InDate")) != DBNull.Value) { obj.InDate = reader.GetDateTime(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InDate")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InContractCode")) != DBNull.Value) { obj.InContractCode = reader.GetString(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InContractCode")); } if (reader.GetValue(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InPrice")) != DBNull.Value) { obj.InPrice = reader.GetDecimal(SqlDataProcess.GetSqlDataReaderFieldIndex(reader, "InPrice")); } } catch (Exception exception) { throw exception; } }