protected override String DoIt() { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_Trx()); if (!(R_InterestArea_ID > 0)) { return(Msg.GetMsg(GetCtx(), "NoInterestAreaIsSelected")); } if (lead.GetC_BPartner_ID() != 0) { VAdvantage.Model.X_R_ContactInterest customer = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx()); customer.SetR_InterestArea_ID(R_InterestArea_ID); customer.SetC_BPartner_ID(lead.GetC_BPartner_ID()); String query = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetC_BPartner_ID(); int UserId = Util.GetValueOfInt(DB.ExecuteScalar(query)); customer.SetAD_User_ID(UserId); query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetC_BPartner_ID(); int Id = Util.GetValueOfInt(DB.ExecuteScalar(query)); VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx()); customer.SetC_BPartner_Location_ID(Id); customer.SetPhone(loc.GetPhone()); customer.SetFax(loc.GetFax()); VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx()); customer.SetC_Job_ID(us.GetC_Job_ID()); customer.SetSubscribeDate(DateTime.Today); query = "Select Email from ad_user where ad_user_id= " + UserId; String mail = Util.GetValueOfString(DB.ExecuteScalar(query)); customer.SetEMail(mail); if (!customer.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(customer.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } else if (lead.GetRef_BPartner_ID() != 0) { VAdvantage.Model.X_R_ContactInterest Prospect = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx()); Prospect.SetR_InterestArea_ID(R_InterestArea_ID); Prospect.SetC_BPartner_ID(lead.GetRef_BPartner_ID()); String query = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetRef_BPartner_ID(); int UserId = Util.GetValueOfInt(DB.ExecuteScalar(query)); Prospect.SetAD_User_ID(UserId); query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetRef_BPartner_ID(); int Id = Util.GetValueOfInt(DB.ExecuteScalar(query)); VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx()); Prospect.SetC_BPartner_Location_ID(Id); Prospect.SetPhone(loc.GetPhone()); Prospect.SetFax(loc.GetFax()); VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx()); Prospect.SetC_Job_ID(us.GetC_Job_ID()); Prospect.SetSubscribeDate(DateTime.Today); query = "Select Email from ad_user where ad_user_id= " + UserId; String mail = Util.GetValueOfString(DB.ExecuteScalar(query)); Prospect.SetEMail(mail); if (!Prospect.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(Prospect.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } else { VAdvantage.Model.X_vss_lead_interestarea Ilead = new VAdvantage.Model.X_vss_lead_interestarea(GetCtx(), 0, Get_Trx()); Ilead.SetC_Lead_ID(lead.GetC_Lead_ID()); Ilead.SetR_InterestArea_ID(R_InterestArea_ID); Ilead.SetAD_User_ID(lead.GetAD_User_ID()); Ilead.SetBPName(lead.GetBPName()); Ilead.SetEMail(lead.GetEMail()); Ilead.SetPhone(lead.GetPhone()); Ilead.SetFax(lead.GetFax()); Ilead.SetAddress1(lead.GetAddress1()); Ilead.SetAddress2(lead.GetAddress2()); Ilead.SetC_City_ID(lead.GetC_City_ID()); Ilead.SetCity(lead.GetCity()); Ilead.SetC_Region_ID(lead.GetC_Region_ID()); Ilead.SetRegionName(lead.GetRegionName()); Ilead.SetC_Country_ID(lead.GetC_Country_ID()); Ilead.SetPostal(lead.GetPostal()); Ilead.SetSubscribeDate(DateTime.Today); if (!Ilead.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(Ilead.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } }
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_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")); }
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(""); }