public int InsertItem(RMAItemInfo oParam) { string sql = @"INSERT INTO RMA_Item ( RMASysNo, ProductSysNo, RMAType, RMAQty, RMADesc ) VALUES ( @RMASysNo, @ProductSysNo, @RMAType, @RMAQty, @RMADesc )"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4); SqlParameter paramRMASysNo = new SqlParameter("@RMASysNo", SqlDbType.Int,4); SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int,4); SqlParameter paramRMAType = new SqlParameter("@RMAType", SqlDbType.Int,4); SqlParameter paramRMAQty = new SqlParameter("@RMAQty", SqlDbType.Int,4); SqlParameter paramRMADesc = new SqlParameter("@RMADesc", SqlDbType.NVarChar,500); if ( oParam.RMASysNo != AppConst.IntNull) paramRMASysNo.Value = oParam.RMASysNo; else paramRMASysNo.Value = System.DBNull.Value; if ( oParam.ProductSysNo != AppConst.IntNull) paramProductSysNo.Value = oParam.ProductSysNo; else paramProductSysNo.Value = System.DBNull.Value; if ( oParam.RMAType != AppConst.IntNull) paramRMAType.Value = oParam.RMAType; else paramRMAType.Value = System.DBNull.Value; if ( oParam.RMAQty != AppConst.IntNull) paramRMAQty.Value = oParam.RMAQty; else paramRMAQty.Value = System.DBNull.Value; if ( oParam.RMADesc != AppConst.StringNull) paramRMADesc.Value = oParam.RMADesc; else paramRMADesc.Value = System.DBNull.Value; cmd.Parameters.Add(paramRMASysNo); cmd.Parameters.Add(paramProductSysNo); cmd.Parameters.Add(paramRMAType); cmd.Parameters.Add(paramRMAQty); cmd.Parameters.Add(paramRMADesc); return SqlHelper.ExecuteNonQuery(cmd); }
private void UpdateRMAItem(RMAItemInfo item) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { new RMADac().UpdateItem(item); scope.Complete(); } }
private void map(RMAItemInfo oParam,DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.RMASysNo = Util.TrimIntNull(tempdr["RMASysNo"]); oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]); oParam.RMAType = Util.TrimIntNull(tempdr["RMAType"]); oParam.RMAQty = Util.TrimIntNull(tempdr["RMAQty"]); oParam.RMADesc = Util.TrimNull(tempdr["RMADesc"]); }
public RMAItemInfo LoadSingleItem(int rmaItemSysNo) { string sql = "select * from RMA_Item where sysno ="+rmaItemSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if(!Util.HasMoreRow(ds)) throw new BizException("This RMA Item doesn't exist"); RMAItemInfo oRMAItem = new RMAItemInfo(); this.map(oRMAItem,ds.Tables[0].Rows[0]); return oRMAItem; }
public RMAInfo Load(int rmaSysNo) { // TransactionOptions options = new TransactionOptions(); // options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; // options.Timeout = TransactionManager.DefaultTimeout; // using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) // { // RMAInfo oRMA = this.LoadMaster(rmaSysNo); // if (oRMA != null) // { // string sql = "select * from RMA_Item where rmasysno =" + rmaSysNo; // DataSet ds = SqlHelper.ExecuteDataSet(sql); // if (Util.HasMoreRow(ds)) // { // foreach (DataRow dr in ds.Tables[0].Rows) // { // RMAItemInfo oRMAItem = new RMAItemInfo(); // this.map(oRMAItem, dr); // string SOItemPODesc = ""; // sql = @"select pm.sysno as posysno,pm.vendorsysno from RMA_Item ri // inner join RMA_Master rm on ri.RMASysNo=rm.sysno // inner join so_master sm on rm.sosysno=sm.sysno // inner join so_item si on sm.sysno=si.sosysno and si.productsysno=ri.productsysno // inner join so_item_po sip on si.sysno=sip.soitemsysno // inner join po_master pm on sip.posysno=pm.sysno // where rm.sysno=" + rmaSysNo + " and ri.productsysno=" + Util.TrimIntNull(dr["ProductSysNo"]); // DataSet dsSOItemPO = SqlHelper.ExecuteDataSet(sql); // foreach (DataRow drSOItemPO in dsSOItemPO.Tables[0].Rows) // { // int POSysNo = Util.TrimIntNull(drSOItemPO["posysno"].ToString()); // int VendorSysNo = Util.TrimIntNull(drSOItemPO["vendorsysno"].ToString()); // SOItemPODesc += "�ɹ�����:<a href=\"javascript:openWindowS2('../Purchase/POSheet.aspx?sysno=" + POSysNo + "&opt=view')" + "\" >" + POSysNo + "</a>, " + "��Ӧ�̱��:<a href=\"javascript:openWindowS2('../Basic/VendorOpt.aspx?sysno=" + VendorSysNo + "&opt=update')" + "\">" + VendorSysNo + "</a><br>"; // } // oRMAItem.SOItemPODesc = SOItemPODesc; // oRMA.ItemHash.Add(oRMAItem.ProductSysNo, oRMAItem); // } // } // } // scope.Complete(); // return oRMA; // } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { RMAInfo oRMA = this.LoadMaster(rmaSysNo); if (oRMA != null) { string sql = "select * from RMA_Item where rmasysno =" + rmaSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { RMAItemInfo oRMAItem = new RMAItemInfo(); this.map(oRMAItem, dr); string SOItemPODesc = ""; sql = @"select isnull(pm.sysno,0) as posysno,isnull(pm.vendorsysno,0) as vendorsysno,isnull(pid.sysno,0) as productidsysno from RMA_Item ri inner join RMA_Master rm on ri.RMASysNo=rm.sysno inner join so_master sm on rm.sosysno=sm.sysno inner join so_item si on sm.sysno=si.sosysno and si.productsysno=ri.productsysno inner join so_item_po sip on si.sysno=sip.soitemsysno left join po_master pm on sip.posysno=pm.sysno left join product_id pid on sip.productidsysno=pid.sysno where rm.sysno=" + rmaSysNo + " and ri.productsysno=" + Util.TrimIntNull(dr["ProductSysNo"]); DataSet dsSOItemPO = SqlHelper.ExecuteDataSet(sql); foreach (DataRow drSOItemPO in dsSOItemPO.Tables[0].Rows) { int POSysNo = Util.TrimIntNull(drSOItemPO["posysno"].ToString()); int VendorSysNo = Util.TrimIntNull(drSOItemPO["vendorsysno"].ToString()); int ProductIDSysNo = Util.TrimIntNull(drSOItemPO["productidsysno"].ToString()); if (POSysNo > 0) { SOItemPODesc += "�ɹ�����:<a href=\"javascript:openWindowS2('../Purchase/POSheet.aspx?sysno=" + POSysNo + "&opt=view')" + "\" >" + POSysNo + "</a>, " + "��Ӧ�̱��:<a href=\"javascript:openWindowS2('../Basic/VendorOpt.aspx?sysno=" + VendorSysNo + "&opt=update')" + "\">" + VendorSysNo + "</a><br>"; } else if (ProductIDSysNo > 0) { SOItemPODesc += "��Ʒ���к�:<a href=\"javascript:openWindowS2('../Basic/ProductID.aspx?sysno=" + ProductIDSysNo + "')" + "\" >" + ProductIDSysNo + "</a><br>"; } } oRMAItem.SOItemPODesc = SOItemPODesc; oRMA.ItemHash.Add(oRMAItem.ProductSysNo, oRMAItem); } } } scope.Complete(); return oRMA; } }
public void Import() { string sql = @"select top 1 * from rma_master; select top 1 * from rma_item;"; DataSet ds = SqlHelper.ExecuteDataSet(sql); foreach(DataTable dt in ds.Tables) { if(Util.HasMoreRow(dt)) throw new BizException("The target is not empty"); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //Insert RMA_Master string sqlMaster = @"select rm.sysno, rmaid, sosysno, customsysno as customersysno, approvetime as audittime, suau.newsysno as auditusersysno, status, rmatime as createtime, note as rmanote,note as ccnote from ipp2003..rma_master rm left join ippconvert..sys_user suau on suau.oldsysno = rm.approversysno"; DataSet dsMaster = SqlHelper.ExecuteDataSet(sqlMaster); if(Util.HasMoreRow(dsMaster)) { foreach(DataRow dr in dsMaster.Tables[0].Rows) { RMAInfo oRMA = new RMAInfo(); oRMA.SysNo = Util.TrimIntNull(dr["SysNo"]); oRMA.RMAID = Util.TrimNull(dr["RMAID"]); oRMA.SOSysNo = Util.TrimIntNull(dr["SOSysNo"]); oRMA.CustomerSysNo = Util.TrimIntNull(dr["CustomerSysNo"]); oRMA.AuditTime = Util.TrimDateNull(dr["AuditTime"]); oRMA.AuditUserSysNo = Util.TrimIntNull(dr["AuditUserSysNo"]); switch((int)dr["Status"]) { case -1: oRMA.Status = (int)AppEnum.RMAStatus.Abandon; break; case 0: oRMA.Status = (int)AppEnum.RMAStatus.Origin; break; case 1: oRMA.Status = (int)AppEnum.RMAStatus.Closed; break; } oRMA.CreateTime = Util.TrimDateNull(dr["CreateTime"]); oRMA.RMANote = Util.TrimNull(dr["RMANote"]); oRMA.CCNote = Util.TrimNull(dr["CCNote"]); oRMA.UserStatus = 1; new RMADac().InsertMaster(oRMA); } } //Insert RMA_Item string sqlItem = @"select 1 as sysno,rmasysno,case realrmatype when 3 then "+(int)AppEnum.RMAType.Overrule+@" when 1 then "+(int)AppEnum.RMAType.Return +@" when 2 then "+(int)AppEnum.RMAType.Maintain+@" end as rmatype, realrmaquantity as rmaqty, realrmareason as rmadesc,pb.newsysno as productsysno from ipp2003..rma_item ri inner join ippconvert..productbasic pb on pb.oldsysno = ri.productsysno"; DataSet dsItem = SqlHelper.ExecuteDataSet(sqlItem); if(Util.HasMoreRow(dsItem)) { foreach(DataRow dr in dsItem.Tables[0].Rows) { RMAItemInfo oRMAItem = new RMAItemInfo(); this.map(oRMAItem,dr); new RMADac().InsertItem(oRMAItem); } } //Insert SnapShot string sqlSnapShot = @"select rmasysno,rmaid,case rmatype when 0 then "+(int)AppEnum.RMAType.Unsure+@" when 1 then "+(int)AppEnum.RMAType.Return +@" when 2 then "+(int)AppEnum.RMAType.Maintain+@" end as rmatype, rmaquantity as rmaqty, rmareason as rmadesc,pb.newsysno as productsysno,pl.productname,p.productid from ipp2003..rma_item ri inner join ippconvert..productbasic pb on pb.oldsysno = ri.productsysno inner join ipp2003..product_language pl on pl.productsysno = ri.productsysno and pl.languageid = 'cn' inner join ipp2003..product p on p.sysno = ri.productsysno inner join ipp2003..rma_master rm on rm.sysno = ri.rmasysno order by rmasysno"; DataSet dsSnapShot = SqlHelper.ExecuteDataSet(sqlSnapShot); if(Util.HasMoreRow(dsSnapShot)) { StringBuilder sb = new StringBuilder(); int tempSysNo = 0; foreach(DataRow dr in dsSnapShot.Tables[0].Rows) { if(tempSysNo!=(int)dr["RMASysNo"]) { if(tempSysNo!=0) { sb.Append("</table>"); Hashtable updateht = new Hashtable(); updateht.Add("SysNo",tempSysNo); updateht.Add("SubmitInfo",sb.ToString()); updateht.Add("ReceiveInfo",sb.ToString()); new RMADac().UpdateMaster(updateht); sb.Remove(0,sb.Length); } sb.Append("<table width='100%' border='1' cellpadding='0' cellspacing='0'>"); sb.Append(" <tr>"); sb.Append(" <td>"+dr["RMAID"].ToString()+"</td>"); sb.Append(" <td>��Ʒ����</td>"); sb.Append(" <td>��������</td>"); sb.Append(" <td>��������</td>"); sb.Append(" <td>����ԭ��</td>"); sb.Append(" </tr>"); } sb.Append("<tr>"); sb.Append(" <td>"+dr["ProductID"].ToString()+"</td>"); sb.Append(" <td>"+dr["ProductName"].ToString()+"</td>"); sb.Append(" <td>"+dr["RMAQty"].ToString()+"</td>"); sb.Append(" <td>"+AppEnum.GetRMAType(Util.TrimIntNull(dr["RMAType"]))+"</td>"); sb.Append(" <td>"+dr["RMADesc"].ToString()+"</td>"); sb.Append("</tr>"); tempSysNo = (int)dr["RMASysNo"]; } } //Insert Sequence string sqlMaxSysNo = @"select max(sysno) as sysno from rma_master"; DataSet dsMaxSysNo = SqlHelper.ExecuteDataSet(sqlMaxSysNo); int n = 0; while(n<Util.TrimIntNull(dsMaxSysNo.Tables[0].Rows[0][0])) { n = SequenceDac.GetInstance().Create("RMA_Sequence"); } scope.Complete(); } }
public RMAInfo BuildRMAfromSO(int soSysNo) { if(!this.IfExistOpenedRMA(soSysNo)) { RMAInfo rmaInfo = new RMAInfo(); SOInfo soInfo = SaleManager.GetInstance().LoadSO(soSysNo); if(soInfo!=null&&soInfo.Status==(int)AppEnum.SOStatus.OutStock) { rmaInfo.SOSysNo = soInfo.SysNo; rmaInfo.CustomerSysNo = soInfo.CustomerSysNo; if(soInfo.ItemHash.Count>0) { foreach(SOItemInfo soItem in soInfo.ItemHash.Values) { RMAItemInfo rmaItem = new RMAItemInfo(); rmaItem.ProductSysNo = soItem.ProductSysNo; rmaItem.RMAType = (int)AppEnum.RMAType.Unsure; rmaItem.RMAQty = soItem.Quantity; rmaInfo.ItemHash.Add(rmaItem.ProductSysNo,rmaItem); string SOItemPODesc = ""; Hashtable ht = SaleManager.GetInstance().LoadSOItemPOList(soItem.SysNo); if(ht != null) { foreach(SOItemPOInfo soItemPO in ht.Keys) { if (soItemPO.POSysNo > 0) { POInfo poInfo = PurchaseManager.GetInstance().LoadPO(soItemPO.POSysNo); int VendorSysNo = poInfo.VendorSysNo; SOItemPODesc += "�ɹ�����:<a href=\"javascript:openWindowS2('../Purchase/POSheet.aspx?sysno=" + soItemPO.POSysNo + "&opt=view')" + "\" >" + soItemPO.POSysNo + "</a>, " + "��Ӧ�̱��:<a href=\"javascript:openWindowS2('../Basic/VendorOpt.aspx?sysno=" + VendorSysNo + "&opt=update')" + "\">" + VendorSysNo + "</a><br>"; } else if(soItemPO.ProductIDSysNo > 0) { SOItemPODesc += "��Ʒ���к�:<a href=\"javascript:openWindowS2('../Basic/ProductID.aspx?sysno=" + soItemPO.ProductIDSysNo + "')" + "\" >" + soItemPO.ProductIDSysNo + "</a><br>"; } } } rmaItem.SOItemPODesc = SOItemPODesc; } } } else rmaInfo = null; return rmaInfo; } else throw new BizException("�����۵��Ѿ�����һ�ű����ڴ����У�������������ύ�µı������룬����ϵORS�̳ǿͷ�"); }