/// <summary> /// 销售列表 /// </summary> /// <returns></returns> private int InsertSheetDetailList(List <t_pm_sheet_detail> sheetDetail, t_pm_sheet_master sheetMaster, SqlTransaction tran) { int num = 0; try { foreach (t_pm_sheet_detail _sheetDetail in sheetDetail) { DataTable dt = (DataTable)this.GetItemInfo(_sheetDetail.item_no).Tables[0]; _sheetDetail.orgi_price = Convert.ToDecimal(dt.Rows[0]["price"].ToString()); SqlParameter[] parameters = { new SqlParameter("@sheet_no", sheetMaster.sheet_no), new SqlParameter("@item_no", _sheetDetail.item_no), new SqlParameter("@order_qty", _sheetDetail.real_qty), new SqlParameter("@real_qty", _sheetDetail.real_qty), new SqlParameter("@large_qty", _sheetDetail.large_qty), new SqlParameter("@orgi_price", _sheetDetail.orgi_price), new SqlParameter("@valid_price", "0.000"), new SqlParameter("@tax", 0.17), new SqlParameter("@valid_date", DateTime.Now), new SqlParameter("@num3", "0.000") }; num = SqlHelper.ExecteNonQuery(SqlTransHelper.conn, tran, CommandType.Text, this.GetSqlInsertSheetDetail(), parameters); } } catch (Exception exception) { throw exception; } return(num); }
public t_pm_sheet_master GetPMSheetDetail(string sheetNO, ref DataTable dt) { StringBuilder strSqlSM = new StringBuilder(); List <SqlParameter> lstSQLParam = new List <SqlParameter>(); strSqlSM.Append("SELECT sheet_no,branch_no,d_branch_no,approve_flag,oper_id,valid_date FROM t_pm_sheet_master where sheet_no=@sheetNO"); lstSQLParam.Add(new SqlParameter("@sheetNO", sheetNO)); DataTable dtSm = SqlHelper.ExecuteDataSet(CommandType.Text, strSqlSM.ToString(), lstSQLParam.ToArray()).Tables[0]; t_pm_sheet_master sm = new t_pm_sheet_master { sheet_no = dtSm.Rows[0]["sheet_no"].ToString(), branch_no = dtSm.Rows[0]["branch_no"].ToString(), approve_flag = dtSm.Rows[0]["approve_flag"].ToString(), d_branch_no = dtSm.Rows[0]["d_branch_no"].ToString(), oper_id = dtSm.Rows[0]["oper_id"].ToString(), valid_date = DateTime.Parse(dtSm.Rows[0]["valid_date"].ToString()) }; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT sd.item_no,ii.item_name,ii.unit_no,sd.real_qty"); strSql.Append(" FROM t_pm_sheet_detail AS sd,t_bd_item_info AS ii"); strSql.Append(" WHERE sd.item_no=ii.item_no and sd.sheet_no=@sheetNO"); SqlParameter[] parameters = { new SqlParameter("@sheetNO", sheetNO.Trim()) }; dt = SqlHelper.ExecuteDataSet(CommandType.Text, strSql.ToString(), parameters).Tables[0]; return(sm); }
/// <summary> /// 终端采购主信息 /// </summary> /// <returns></returns> public string InPMSheetMaster(t_pm_sheet_master _sheetMaster) { int num; //总价格 decimal?sheetAmt = 0; List <t_pm_sheet_detail> sheetDetail = new List <t_pm_sheet_detail>(_sheetMaster.detailList); foreach (t_pm_sheet_detail _sd in sheetDetail) { DataTable dt = (DataTable)this.GetItemInfo(_sd.item_no).Tables[0]; sheetAmt = Convert.ToDecimal(dt.Rows[0]["price"].ToString()) * _sd.real_qty; } _sheetMaster.sheet_no = "YH" + _sheetMaster.branch_no + this.GetSheetMasterNo(); SqlParameter[] parameters = { new SqlParameter("@sheet_no", _sheetMaster.sheet_no), new SqlParameter("@trans_no", "YH"), new SqlParameter("@db_no", "+"), new SqlParameter("@branch_no", _sheetMaster.branch_no), new SqlParameter("@d_branch_no", _sheetMaster.d_branch_no), new SqlParameter("@supcust_no", _sheetMaster.oper_id), new SqlParameter("@approve_flag", '0'), new SqlParameter("@oper_date", DateTime.Now), new SqlParameter("@order_status", "0"), new SqlParameter("@oper_id", _sheetMaster.oper_id), new SqlParameter("@confirm_man", ""), new SqlParameter("@sale_way", "A"), new SqlParameter("@sheet_amt", sheetAmt), new SqlParameter("@memo", "测试") }; SqlTransaction tran = null; try { tran = SqlTransHelper.GetSqlTransaction(); num = SqlHelper.ExecteNonQuery(SqlTransHelper.conn, tran, CommandType.Text, this.GetSqlInsertSheetMaster(), parameters); num = this.InsertSheetDetailList(new List <t_pm_sheet_detail>(_sheetMaster.detailList), _sheetMaster, tran); } catch (Exception exception) { tran.Rollback(); SqlTransHelper.Close(); tran.Dispose(); throw exception; } tran.Commit(); tran.Dispose(); SqlTransHelper.Close(); return(_sheetMaster.sheet_no); }
/// <summary> /// 终端要货主信息 /// </summary> /// <returns></returns> public string InPMSheetMaster(t_pm_sheet_master _sheetMaster) { return(dal.InPMSheetMaster(_sheetMaster)); }