//String query1 = "Select Ad_User_id from Ad_user where C_bpartner_id=1001864"; //int AD_Id = Util.GetValueOfInt(DB.ExecuteScalar(query1)); //X_AD_User user = new X_AD_User(GetCtx(), AD_Id, null); //return ""; // query = "Select C_TargetList_id from C_TargetList where C_TargetList_id not in (Select C_TargetList_id from C_InviteeList) and c_campaign_id="+Record_ID; //IDataReader dr = DB.ExecuteReader(query); //while (dr.Read()) //{ // X_C_TargetList TList = new X_C_TargetList(GetCtx(), Util.GetValueOfInt(dr[0]), Get_Trx()); // if (TList.GetC_BPartner_ID()!=0) // { // invitee(Util.GetValueOfInt(dr[0])); // } // if (TList.GetRef_BPartner_ID() !=0) // { // invitee( Util.GetValueOfInt(dr[0])); // } // if (TList.GetC_Lead_ID() != 0) // { // X_C_Lead lead = new X_C_Lead(GetCtx(), TList.GetC_Lead_ID(), Get_Trx()); // if (lead.GetC_BPartner_ID() != 0) // { // invitee(lead.GetC_BPartner_ID()); // } // else if (lead.GetRef_BPartner_ID() !=0) // { // invitee( Util.GetValueOfInt(dr[0])); // } // else if (lead.GetContactName() !=null) // { // X_C_InviteeList Invt = new X_C_InviteeList(GetCtx(), 0, Get_Trx()); // Invt.SetC_TargetList_ID(Util.GetValueOfInt(dr[0])); // Invt.SetName(lead.GetContactName()); // Invt.SetEMail(lead.GetEMail()); // Invt.SetPhone(lead.GetPhone()); // Invt.SetC_Lead_ID(lead.GetC_Lead_ID()); // if (!Invt.Save()) // { // } // } // } //} //return ""; public void invitee(int bpid) { VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bpid, Get_Trx()); String query = "Select Ad_User_id from Ad_user where C_bpartner_id=" + bpid; int AD_Id = Util.GetValueOfInt(DB.ExecuteScalar(query, null, Get_Trx())); string sql = "Select C_InviteeList_id from C_InviteeList where Ad_User_id=" + AD_Id + " and C_Campaign_id=" + GetRecord_ID(); object id = DB.ExecuteScalar(sql, null, Get_Trx()); VAdvantage.Model.X_C_InviteeList Invt; if (Util.GetValueOfInt(id) != 0) { Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), Util.GetValueOfInt(id), Get_Trx()); } else { Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), 0, Get_Trx()); Invt.SetAD_User_ID(AD_Id); } VAdvantage.Model.X_AD_User user = new VAdvantage.Model.X_AD_User(GetCtx(), AD_Id, Get_Trx()); int BpLoc = user.GetC_BPartner_Location_ID(); if (BpLoc != 0) { String Sql = "Select C_Location_ID From C_Bpartner_location where C_Bpartner_location_id=" + BpLoc; Invt.SetC_Location_ID(Util.GetValueOfInt(DB.ExecuteScalar(Sql))); } Invt.SetC_Campaign_ID(GetRecord_ID()); Invt.SetName(user.GetName()); Invt.SetEMail(user.GetEMail()); Invt.SetPhone(user.GetPhone()); // Invt.SetURL(url); if (!Invt.Save(Get_Trx())) { Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); } string ID = Invt.GetC_InviteeList_ID().ToString(); string encrypt = FormsAuthentication.HashPasswordForStoringInConfigFile(ID, "SHA1"); string urlFinal = ""; urlFinal = url + "?" + encrypt; sql = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID(); int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx())); //Random rand = new Random(); //String s = ""; //for (int i = 0; i < 9; i++) // s = String.Concat(s, rand.Next(10).ToString()); //string urlFinal = ""; ////// urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString(); //urlFinal = url + "?" + s; //sql = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID(); //int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx())); //Invt.SetURL(urlFinal); //if (!Invt.Save(Get_Trx())) //{ // Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); //} }
protected override String DoIt() { string Sql = "Select C_Lead_ID From C_Lead where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID(); IDataReader dr = DB.ExecuteReader(Sql); try { while (dr.Read()) { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), null); lead.SetSalesRep_ID(ToSalesRep_ID); lead.Save(); { } } dr.Close(); Sql = "Select C_Project_ID From C_Project where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID(); dr = DB.ExecuteReader(Sql); while (dr.Read()) { VAdvantage.Model.X_C_Project Project = new VAdvantage.Model.X_C_Project(GetCtx(), Util.GetValueOfInt(dr[0]), null); Project.SetSalesRep_ID(ToSalesRep_ID); Project.Save(); { } } dr.Close(); Sql = "Select C_BPartner_ID From C_BPartner where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID(); dr = DB.ExecuteReader(Sql); while (dr.Read()) { VAdvantage.Model.X_C_BPartner BP = new VAdvantage.Model.X_C_BPartner(GetCtx(), Util.GetValueOfInt(dr[0]), null); BP.SetSalesRep_ID(ToSalesRep_ID); BP.Save(); { } } dr.Close(); return(Msg.GetMsg(GetCtx(), "RecordsTransferedSuccessfully"));; } catch { if (dr != null) { dr.Close(); } return(Msg.GetMsg(GetCtx(), "RecordsnotTransfered"));; } }
protected override String DoIt() { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName()); // lead.GetRef_BPartner_ID())) int ExCustomer = lead.GetC_BPartner_ID(); int Pospect = lead.GetRef_BPartner_ID(); if (ExCustomer != 0) { VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); opp.SetC_Lead_ID(lead.GetC_Lead_ID()); opp.SetC_BPartner_ID(lead.GetC_BPartner_ID()); opp.SetSalesRep_ID(lead.GetSalesRep_ID()); opp.SetDateContract(DateTime.Today); opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); //opp.SetR_Source_ID (lead.GetR_Source_ID()); // opp.SetOpportunityStatus("N"); opp.SetAD_User_ID(lead.GetAD_User_ID()); VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName()); //VAdvantage.Model.X_C_BPartner_Location loc=new VAdvantage.Model.X_C_BPartner_Location (GetCtx(),ExCustomer,Get_TrxName()); opp.SetName(bp.GetName());; opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); opp.SetIsOpportunity(true); if (opp.Save()) { lead.SetC_Project_ID(opp.GetC_Project_ID()); lead.Save(); return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone")); } else { return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone")); } } if (Pospect != 0) { VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); opp.SetC_Lead_ID(lead.GetC_Lead_ID()); opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID()); opp.SetSalesRep_ID(lead.GetSalesRep_ID()); opp.SetDateContract(DateTime.Today); opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); // opp.SetR_Source_ID (lead.GetR_Source_ID()); //opp.SetOpportunityStatus ("N"); // opp.SetAD_Client_ID(GetAD_Client_ID()); opp.SetAD_User_ID(lead.GetAD_User_ID()); VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName()); //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName()); opp.SetName(bp.GetName()); opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); opp.SetIsOpportunity(true); if (opp.Save()) { lead.SetC_Project_ID(opp.GetC_Project_ID()); lead.Save(); return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone")); } else { return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone")); } } if (ExCustomer == 0 && Pospect == 0) { //CallProcess(_C_Lead_ID); if (lead.GetBPName() == null) { return(Msg.GetMsg(GetCtx(), "Company Name, Prospect or Bpartner is Mandatory to fill")); } callprospect(); return(DoIt()); } return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone")); }
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { log.Info("C_Order_ID=" + _C_Order_ID + ", C_DocType_ID=" + _C_DocType_ID + ", CloseDocument=" + _IsCloseDocument); if (_C_Order_ID == 0) { throw new ArgumentException("No Order"); } VAdvantage.Model.MDocType dt = VAdvantage.Model.MDocType.Get(GetCtx(), _C_DocType_ID); if (dt.Get_ID() == 0) { throw new ArgumentException("No DocType"); } if (_DateDoc == null) { _DateDoc = Util.GetValueOfDateTime(DateTime.Now); } // VAdvantage.Model.MOrder from = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); VAdvantage.Model.MOrder newOrder = VAdvantage.Model.MOrder.CopyFrom(from, _DateDoc, dt.GetC_DocType_ID(), false, true, null); // copy ASI newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); int C_Bpartner_ID = newOrder.GetC_BPartner_ID(); //Update New Order Refrence From Sales Qutation in Sales order newOrder.SetPOReference(Util.GetValueOfString(from.GetDocumentNo())); String sqlbp = "update c_project set c_bpartner_id=" + C_Bpartner_ID + " where ref_order_id=" + _C_Order_ID + ""; int value = DB.ExecuteQuery(sqlbp, null, Get_Trx()); bool OK = newOrder.Save(); if (!OK) { throw new Exception("Could not create new Order"); } if (OK) { string sql = "select C_Project_id from c_project where c_order_id = " + from.GetC_Order_ID(); int C_Project_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); if (C_Project_ID != 0) { VAdvantage.Model.X_C_Project project = new VAdvantage.Model.X_C_Project(GetCtx(), C_Project_ID, Get_Trx()); project.SetC_BPartner_ID(project.GetC_BPartnerSR_ID()); project.SetC_BPartnerSR_ID(0); if (!project.Save()) { } } from.SetRef_Order_ID(newOrder.GetC_Order_ID()); from.Save(); int bp = newOrder.GetC_BPartner_ID(); VAdvantage.Model.X_C_BPartner prosp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bp, Get_Trx()); prosp.SetIsCustomer(true); prosp.SetIsProspect(false); prosp.Save(); } // if (_IsCloseDocument) { VAdvantage.Model.MOrder original = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Complete); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Complete); original.Save(); original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Close); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Close); original.Save(); } // return(Msg.GetMsg(GetCtx(), "OrderCreatedSuuccessfully")); //return dt.GetName() + ": " + newOrder.GetDocumentNo(); }
protected override String DoIt() { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName()); // lead.GetRef_BPartner_ID())) int ExCustomer = lead.GetC_BPartner_ID(); int Pospect = lead.GetRef_BPartner_ID(); if (ExCustomer != 0) { VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); opp.SetAD_Client_ID(lead.GetAD_Client_ID()); opp.SetAD_Org_ID(lead.GetAD_Org_ID()); opp.SetC_Lead_ID(lead.GetC_Lead_ID()); opp.SetC_BPartner_ID(lead.GetC_BPartner_ID()); // Addde by Bharat on 19 Feb 2018 to set Ref Partner/Prospect if (opp.Get_ColumnIndex("Ref_BPartner_ID") > 0) { opp.SetRef_BPartner_ID(lead.GetC_BPartner_ID()); } opp.SetSalesRep_ID(lead.GetSalesRep_ID()); opp.SetDateContract(DateTime.Today); opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); //opp.SetR_Source_ID (lead.GetR_Source_ID()); // opp.SetOpportunityStatus("N"); opp.SetAD_User_ID(lead.GetAD_User_ID()); VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName()); //VAdvantage.Model.X_C_BPartner_Location loc=new VAdvantage.Model.X_C_BPartner_Location (GetCtx(),ExCustomer,Get_TrxName()); opp.SetName(bp.GetName());; opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); opp.SetIsOpportunity(true); /*Vivek*/ opp.SetC_EnquiryRdate(lead.GetC_EnquiryRdate()); if (lead.GetC_ProposalDdate() != null) { opp.SetC_ProposalDdate(Convert.ToDateTime(lead.GetC_ProposalDdate()).ToLocalTime()); } else { opp.SetC_ProposalDdate(lead.GetC_ProposalDdate()); } if (opp.Save()) { lead.SetC_Project_ID(opp.GetC_Project_ID()); lead.Save(); return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone")); } else { return(GetRetrievedError(opp, "OpprtunityGenerateNotDone")); //return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"); } } if (Pospect != 0) { VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); opp.SetAD_Client_ID(lead.GetAD_Client_ID()); opp.SetAD_Org_ID(lead.GetAD_Org_ID()); opp.SetC_Lead_ID(lead.GetC_Lead_ID()); opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID()); // Addde by Bharat on 19 Feb 2018 to set Ref Partner/Prospect if (opp.Get_ColumnIndex("Ref_BPartner_ID") > 0) { opp.SetRef_BPartner_ID(lead.GetRef_BPartner_ID()); } opp.SetSalesRep_ID(lead.GetSalesRep_ID()); opp.SetDateContract(DateTime.Today); opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); // opp.SetR_Source_ID (lead.GetR_Source_ID()); //opp.SetOpportunityStatus ("N"); // opp.SetAD_Client_ID(GetAD_Client_ID()); opp.SetAD_User_ID(lead.GetAD_User_ID()); VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName()); //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName()); opp.SetName(bp.GetName()); opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); opp.SetIsOpportunity(true); /*Vivek*/ opp.SetC_EnquiryRdate(lead.GetC_EnquiryRdate()); if (lead.GetC_ProposalDdate() != null) { opp.SetC_ProposalDdate(Convert.ToDateTime(lead.GetC_ProposalDdate()).ToLocalTime()); } else { opp.SetC_ProposalDdate(lead.GetC_ProposalDdate()); } if (opp.Save()) { lead.SetC_Project_ID(opp.GetC_Project_ID()); lead.Save(); return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone")); } else { return(GetRetrievedError(opp, "OpprtunityGenerateNotDone")); //return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"); } } if (ExCustomer == 0 && Pospect == 0) { //CallProcess(_C_Lead_ID); if (lead.GetBPName() == null) { return(Msg.GetMsg(GetCtx(), "Company Name, Prospect or Bpartner is Mandatory to fill")); } callprospect(); return(DoIt()); } return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone")); }
protected override string DoIt() { VAdvantage.Model.X_C_BPartner partner = new VAdvantage.Model.X_C_BPartner(GetCtx(), GetRecord_ID(), null); string _BPName = partner.GetName(); string _sql = "Select C_Lead_ID From C_Lead Where BPName='" + _BPName + "' AND IsActive = 'Y' AND AD_Client_ID = " + GetAD_Client_ID(); DataSet ds = new DataSet(); ds = DB.ExecuteDataset(_sql.ToString()); if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { _C_Lead_ID = Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Lead_ID"]); VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName()); // lead.GetRef_BPartner_ID())) //int ExCustomer = lead.GetC_BPartner_ID(); int Pospect = lead.GetRef_BPartner_ID(); if (Pospect != 0) { VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); opp.SetC_Lead_ID(lead.GetC_Lead_ID()); opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID()); opp.SetSalesRep_ID(lead.GetSalesRep_ID()); opp.SetDateContract(DateTime.Today); opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); // opp.SetR_Source_ID (lead.GetR_Source_ID()); //opp.SetOpportunityStatus ("N"); // opp.SetAD_Client_ID(GetAD_Client_ID()); opp.SetAD_User_ID(lead.GetAD_User_ID()); VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName()); //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName()); opp.SetName(bp.GetName()); opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); opp.SetIsOpportunity(true); if (opp.Save()) { lead.SetC_Project_ID(opp.GetC_Project_ID()); lead.Save(); bp.SetCreateProject("Y"); if (bp.Save()) { } return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone")); } else { return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone")); } } //if (ExCustomer != 0) //{ // VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName()); // opp.SetC_Lead_ID(lead.GetC_Lead_ID()); // opp.SetC_BPartner_ID(lead.GetC_BPartner_ID()); // opp.SetSalesRep_ID(lead.GetSalesRep_ID()); // opp.SetDateContract(DateTime.Today); // opp.SetC_Campaign_ID(lead.GetC_Campaign_ID()); // opp.SetR_Source_ID(lead.GetR_Source_ID()); // opp.SetOpportunityStatus("N"); // opp.SetAD_User_ID(lead.GetAD_User_ID()); // VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName()); // VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), ExCustomer, Get_TrxName()); // opp.SetName(bp.GetName()); ; // opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID()); // opp.SetIsOpportunity(true); // if (opp.Save()) // { // lead.SetC_Project_ID(opp.GetC_Project_ID()); // lead.Save(); // return Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"); // } // else // { // return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"); // } //} } } return(""); }
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { log.Info("C_Order_ID=" + _C_Order_ID + ", C_DocType_ID=" + _C_DocType_ID + ", CloseDocument=" + _IsCloseDocument); if (_C_Order_ID == 0) { throw new ArgumentException("No Order"); } VAdvantage.Model.MDocType dt = VAdvantage.Model.MDocType.Get(GetCtx(), _C_DocType_ID); if (dt.Get_ID() == 0) { throw new ArgumentException("No DocType"); } if (_DateDoc == null) { _DateDoc = Util.GetValueOfDateTime(DateTime.Now); } // VAdvantage.Model.MOrder from = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); if (from.GetDocStatus() != "DR" && from.GetDocStatus() != "IP" && from.GetDocStatus() != "CO") { throw new Exception("Order Closed"); } VAdvantage.Model.MOrder newOrder = VAdvantage.Model.MOrder.CopyFrom(from, _DateDoc, dt.GetC_DocType_ID(), false, true, null); // copy ASI newOrder.SetC_DocTypeTarget_ID(_C_DocType_ID); int C_Bpartner_ID = newOrder.GetC_BPartner_ID(); newOrder.Set_Value("IsSalesQuotation", false); // Added by Bharat on 05 Jan 2018 to set Values on Blanket Sales Order from Sales Quotation. if (dt.GetDocBaseType() == "BOO") { newOrder.Set_Value("IsBlanketTrx", true); } else // Added by Bharat on 29 March 2018 to set Blanket Order zero in case of Sales order Creation. { newOrder.SetC_Order_Blanket(0); } if (newOrder.Get_ColumnIndex("C_Order_Quotation") > 0) { newOrder.SetC_Order_Quotation(_C_Order_ID); } //Update New Order Refrence From Sales Qutation in Sales order newOrder.SetPOReference(Util.GetValueOfString(from.GetDocumentNo())); // Added by Bharat on 31 Jan 2018 to set Inco Term from Quotation if (newOrder.Get_ColumnIndex("C_IncoTerm_ID") > 0) { newOrder.SetC_IncoTerm_ID(from.GetC_IncoTerm_ID()); } String sqlbp = "update c_project set c_bpartner_id=" + C_Bpartner_ID + " where ref_order_id=" + _C_Order_ID + ""; int value = DB.ExecuteQuery(sqlbp, null, Get_Trx()); bool OK = newOrder.Save(); if (!OK) { //return GetReterivedError( newOrder, "Could not create new Order"); throw new Exception("Could not create new Order"); } if (OK) { string sql = "select C_Project_id from c_project where c_order_id = " + from.GetC_Order_ID(); int C_Project_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); if (C_Project_ID != 0) { VAdvantage.Model.X_C_Project project = new VAdvantage.Model.X_C_Project(GetCtx(), C_Project_ID, Get_Trx()); project.SetC_BPartner_ID(project.GetC_BPartnerSR_ID()); project.SetC_BPartnerSR_ID(0); if (!project.Save()) { log.SaveError("Error on " + project.Get_TableName(), ""); } } if (dt.GetDocBaseType() == "BOO") { from.SetC_Order_Blanket(newOrder.GetC_Order_ID()); } else { from.SetRef_Order_ID(newOrder.GetC_Order_ID()); } from.Save(); int bp = newOrder.GetC_BPartner_ID(); VAdvantage.Model.X_C_BPartner prosp = new VAdvantage.Model.X_C_BPartner(GetCtx(), bp, Get_Trx()); prosp.SetIsCustomer(true); prosp.SetIsProspect(false); if (!prosp.Save()) { log.SaveError("Error on " + prosp.Get_TableName(), ""); } } // if (_IsCloseDocument) { VAdvantage.Model.MOrder original = new VAdvantage.Model.MOrder(GetCtx(), _C_Order_ID, Get_Trx()); //Edited by Arpit Rai on 8th of Nov,2017 if (original.GetDocStatus() != "CO") //to check if document is already completed { original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Complete); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Complete); original.Save(); } //Arpit original.SetDocAction(VAdvantage.Model.MOrder.DOCACTION_Close); original.ProcessIt(VAdvantage.Model.MOrder.DOCACTION_Close); original.Save(); } // return(Msg.GetMsg(GetCtx(), "OrderCreatedSuccessfully") + " - " + dt.GetName() + ": " + newOrder.GetDocumentNo()); }