Exemplo n.º 1
0
 public bool SaveSalesOrderDraftToJFZ(OM_SalesOrderDataObject salesOrder, OM_B1InfomationDTO b1Informaion)
 {
     if (!this.JFZConnect())
     {
         return false;
     }
     SAPbobsCOM.Recordset oRs = jFZCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     oRs.DoQuery(string.Format("select * from ODRF where ObjType='17' and Address2='{0}'", salesOrder.Guid));
     if (oRs.RecordCount > 0)
     {
         b1Informaion.JFZCode = 200;
         b1Informaion.JFZStatus = OMDocStatus.Commit;
         b1Informaion.JFZMessage = string.Format("This order hac commit to SAP");
         LogHelper.Info(string.Format("JFZCompnay Document has exist, and the DocEntry={0},DocNum={1}", oRs.Fields.Item("DocEntry").Value, oRs.Fields.Item("DocNum").Value));
         return true;
     }
     oRs.DoQuery(string.Format("select top 1 CardCode from OCRD where CardName='{0}'", salesOrder.CardName.Trim()));
     if (oRs.RecordCount > 0)
     {
         SAPbobsCOM.Documents oSaleOrder = JFZCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
         try
         {
             oSaleOrder.Address = salesOrder.Guid;
             oSaleOrder.CardCode = oRs.Fields.Item("CardCode").Value;
             oSaleOrder.CardName = salesOrder.CardName;
             oSaleOrder.Comments = "营销远程平台对接生成";
             if (salesOrder.DocDate == null)
             {
                 oSaleOrder.DocDate = DateTime.Now;
             }
             else if (salesOrder.DocDueDate == null)
             {
                 oSaleOrder.DocDueDate = DateTime.Now;
             }
             else
             {
                 oSaleOrder.DocDate = (DateTime)salesOrder.DocDate;
                 oSaleOrder.DocDueDate = (DateTime)salesOrder.DocDueDate;
             }
             oSaleOrder.DocObjectCode = SAPbobsCOM.BoObjectTypes.oOrders;
             foreach (var item in salesOrder.SalesOrderLine)
             {
                 oSaleOrder.Lines.ItemCode = item.ItemCode;
                 oSaleOrder.Lines.ItemDescription = item.ItemName;
                 oSaleOrder.Lines.Quantity = Convert.ToDouble(item.Quantity);
                 oSaleOrder.Lines.Price = Convert.ToDouble(item.InnerPrice);
                 oSaleOrder.Lines.Add();
                 //LogHelper.Info(string.Format("the OsaleOrderLine Detail ItemCode={0},ItemName={1},Quantity={2},Price={3}", item.ItemCode.ToString(), item.ItemName, item.Quantity, item.Price));
             }
             //LogHelper.Info(string.Format("the OsaleOrder Detail CardeCode={0},CardName={1},DocDate={2},DocDueDate={3}", oSaleOrder.CardCode.ToString(), oSaleOrder.CardName, oSaleOrder.DocDate.ToString("yyyyMMdd"), oSaleOrder.DocDueDate.ToString("yyyyMMdd")));
             if (oSaleOrder.Add() == 0)
             {
                 b1Informaion.JFZCode = 200;
                 b1Informaion.JFZStatus = OMDocStatus.Commit;
                 b1Informaion.JFZMessage = string.Format("金方子:{0},订单号:{1}对接成功", salesOrder.CardCode, salesOrder.DocEntry);
                 LogHelper.Info(string.Format("金方子:{0},订单号:{1}对接成功", salesOrder.CardCode, salesOrder.DocEntry));
                 return true;
             }
             b1Informaion.JFZCode = -1;
             b1Informaion.JFZStatus = OMDocStatus.Unchange;
             b1Informaion.JFZMessage = string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", JFZCompany.GetLastErrorCode().ToString(), JFZCompany.GetLastErrorDescription());
             LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", JFZCompany.GetLastErrorCode().ToString(), JFZCompany.GetLastErrorDescription()));
             return false;
         }
         catch (Exception ex)
         {
             b1Informaion.JFZCode = -1;
             b1Informaion.JFZStatus = OMDocStatus.Unchange;
             b1Informaion.JFZMessage = string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", JFZCompany.GetLastErrorCode().ToString(), JFZCompany.GetLastErrorDescription());
             LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", JFZCompany.GetLastErrorCode().ToString(), JFZCompany.GetLastErrorDescription()));
             return false;
         }
         finally
         {
             JFZDisConnect();
         }
     }
     else
     {
         LogHelper.Error("金方子客户代码为空");
         throw new GenericException("金方子客户代码为空");
     }
 }
Exemplo n.º 2
0
 public bool SaveSalesOrderDraft(OM_SalesOrderDataObject salesOrder, OM_B1InfomationDTO b1Informaion)
 {
     if (!this.Connect())
     {
         return false;
     }
     SAPbobsCOM.Recordset oRs = CurrentCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     LogHelper.Info(string.Format("GSCompany via script is: select * from ODRF where ObjType='17' and Address2='{0}'", salesOrder.Guid));
     oRs.DoQuery(string.Format("select * from ODRF where ObjType='17' and Address2='{0}'", salesOrder.Guid));
     if (oRs.RecordCount > 0)
     {
         b1Informaion.GSCode = 200;
         b1Informaion.GSStatus = OMDocStatus.Commit;
         b1Informaion.JFZMessage = string.Format("This Order-{0}-{1} has commit to SAP", salesOrder.Guid, oRs.Fields.Item("DocEntry").Value);
         LogHelper.Info(string.Format("JFZCompnay Document has exist, and the DocEntry={0},DocNum={1}", oRs.Fields.Item("DocEntry").Value, oRs.Fields.Item("DocNum").Value));
         return true;
     }
     SAPbobsCOM.Documents oSaleOrder = CurrentCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
     try
     {
         oSaleOrder.Address2 = salesOrder.Guid;
         oSaleOrder.CardCode = salesOrder.CardCode;
         oSaleOrder.CardName = salesOrder.CardName;
         oSaleOrder.Comments = "营销远程平台对接生成";
         if (salesOrder.DocDate == null)
         {
             oSaleOrder.DocDate = DateTime.Now;
             oSaleOrder.DocDueDate = DateTime.Now;
         }
         else if (salesOrder.DocDueDate == null)
         {
             oSaleOrder.DocDueDate = DateTime.Now;
         }
         else
         {
             oSaleOrder.DocDate = (DateTime)salesOrder.DocDate;
             oSaleOrder.DocDueDate = (DateTime)salesOrder.DocDueDate;
         }
         oSaleOrder.DocObjectCode = SAPbobsCOM.BoObjectTypes.oOrders;
         foreach (var item in salesOrder.SalesOrderLine)
         {
             oSaleOrder.Lines.ItemCode = item.ItemCode;
             oSaleOrder.Lines.ItemDescription = item.ItemName;
             oSaleOrder.Lines.Quantity = Convert.ToDouble(item.Quantity);
             oSaleOrder.Lines.Price = Convert.ToDouble(item.InnerPrice);
             oSaleOrder.Lines.Add();
         }
         if (oSaleOrder.Add() == 0)
         {
             b1Informaion.GSCode = 200;
             b1Informaion.GSStatus = OMDocStatus.Commit;
             b1Informaion.GSMessage = (string.Format("高山药业:{0},订单号:{1}对接成功,update ", salesOrder.CardCode, salesOrder.DocEntry));
             LogHelper.Info(string.Format("高山药业:{0},订单号:{1}对接成功,update ", salesOrder.CardCode, salesOrder.DocEntry));
             return true;
         }
         b1Informaion.GSCode = -1;
         b1Informaion.GSStatus = OMDocStatus.Unchange;
         b1Informaion.GSMessage = string.Format("GSSalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription());
         LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription()));
         return false;
     }
     catch (Exception ex)
     {
         b1Informaion.GSCode = -1;
         b1Informaion.GSStatus = OMDocStatus.Unchange;
         b1Informaion.GSMessage = string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription());
         LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription()));
         return false;
     }
     finally
     {
         DisConnect();
     }
 }