protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("google");
            try
            {
                IOrganizationService service;
                string userName = "******";
                string password = "******";
                string orgUrl   = "https://edusysglobalservices.api.crm5.dynamics.com/XRMServices/2011/Organization.svc";
                service = EDUsys.CreateService(userName, password, orgUrl);

                DataTable dtTable = EDUsys.GetContacts(service, 1, TextBox1.Text);
                //     EDUsys.GetContacts(service, 1, "Su");
                if (dtTable.Rows.Count > 0)
                {
                    GridView1.DataSource = dtTable;
                    GridView1.DataBind();
                }
                else
                {
                    Response.Write("No data found");
                }
            }

            catch (Exception l) {
                Response.Write(l.Message);
            }
        }
        //algo to delete quote from CRM
        public void DELETE_FROM_CRM(string[] arr1, string[] arr2)
        //arr1 contains prev quote item code
        //arr1 contains latest quote item code
        {
            IOrganizationService service = connection_to_crm();
            int flag = 0;

            for (int i = 0; i < arr1.Length; i++)
            {
                flag = 0;
                for (int j = 0; j < arr2.Length; j++)
                {
                    if (arr1[i].Equals(arr2[j]))
                    {
                        flag = 1;
                        break;
                    }
                }
                if (flag == 0)
                {
                    QuoteGUID    = "";
                    LineItemGUID = "";
                    bool isDeleted = EDUsys.DeleteLineItem(service, QuoteGUID, LineItemGUID);
                }
            }
        }
        //algo to write code to update and add new Quote with line items
        public void UPDATE_FROM_CRM(string[] arr1, string[] arr2)
        //arr1 contains prev quote item code
        //arr1 contains latest quote item code
        {
            IOrganizationService service = connection_to_crm();
            int flag = 0;

            for (int j = 0; j < arr2.Length; j++) // loop th 2 nd array contains latest Quote id
            {
                flag = 0;
                for (int i = 0; i < arr1.Length; i++)
                {
                    if (arr2[j].Equals(arr1[i]))
                    {
                        //update in crm
                        flag = 1;
                        break;
                    }
                }
                if (flag == 1)
                {
                    //update line items with prev GUID

                    QuoteGUID    = "";
                    LineItemGUID = "";
                    bool isUpdated1 = EDUsys.UpdateWriteInLineItem(service, QuoteGUID, LineItemGUID, ItemDescription, PricePerUnit, Quantity);
                    //update in vmquotes also
                }
                else if (flag == 0)
                {
                    if (option.Equals("R1"))
                    {
                        // Add line items with prev QUOTE GUID
                        string AddedProductGUID = EDUsys.AddWriteInLineItem(service, QuoteGUID, ItemDescription, PricePerUnit, Quantity);
                        // update in vmquotes also for next time
                    }
                    else if (option.Equals("A1"))
                    {
                        // create new Quote Guid n add line items in this id
                        //    string QuoteGUID = EDUsys.CreateQuote(service, string topic, string ContactGUID, DateTime estCloseDate, int probabiliy, int Phase, int Rating, string OwnerUserGUID, bool Revenue, decimal EstRevenue, decimal DiscountPercent, decimal DiscountAmount, string PriceListGUID);
                        //  string AddedProductGUID = EDUsys. AddWriteInLineItem(service, string QuoteGUID, string ItemDescription, decimal PricePerUnit, decimal Quantity);
                        // update in vmquotes also for next time
                    }
                }
            }
        }
Exemple #4
0
        public IOrganizationService connection_to_crm()
        {
            IOrganizationService service = null;

            try
            {
                string userName = TextBox1.Text; //"*****@*****.**";
                string password = TextBox2.Text; //"Saxu0104";
                string orgUrl   = "https://edusysglobalservices.api.crm5.dynamics.com/XRMServices/2011/Organization.svc";
                service = EDUsys.CreateService(userName, password, orgUrl);

                return(service);
            }
            catch (Exception v)
            {
                Response.Write(v.Message);
            }
            return(service);
        }
 public void connection_to_crm()
 {
     try
     {
         IOrganizationService service;
         string userName      = "******";
         string password      = "******";
         string OwnerFullName = "Quote VMEdu";
         string orgUrl        = "https://edusysglobalservices.api.crm5.dynamics.com/XRMServices/2011/Organization.svc";
         service = EDUsys.CreateService(userName, password, orgUrl);
         string ownerUserGUID = EDUsys.ValidateOwnerWithCRMUser(service, OwnerFullName);
         Response.Write("The owner guid is " + ownerUserGUID);
         //string QuoteGUID = EDUsys.CreateQuote(service, string topic, string ContactGUID, DateTime estCloseDate, int probabiliy, int Phase, int Rating, string OwnerUserGUID, bool Revenue, decimal EstRevenue, decimal DiscountPercent, decimal ProductTotal, decimal DiscountAmount, decimal PreFreightAmount, decimal TotalAmount, int Quantity, decimal PricePerUnit, decimal ExtendedAmount);
     }
     catch (Exception v)
     {
         Response.Write(v.Message);
     }
 }
        public IOrganizationService connection_to_crm()
        {
            IOrganizationService service = null;

            try
            {
                string userName = "******";
                string password = "******";
                string orgUrl   = "https://edusysglobalservices.api.crm5.dynamics.com/XRMServices/2011/Organization.svc";
                service = EDUsys.CreateService(userName, password, orgUrl);
                return(service);
                //dtTable = EDUsys.GetContacts(service, 3, search_key);// search by last name(3)
                /// Response.Write("The owner guid is "+ownerUserGUID);
                //string QuoteGUID = EDUsys.CreateQuote(service, string topic, string ContactGUID, DateTime estCloseDate, int probabiliy, int Phase, int Rating, string OwnerUserGUID, bool Revenue, decimal EstRevenue, decimal DiscountPercent, decimal ProductTotal, decimal DiscountAmount, decimal PreFreightAmount, decimal TotalAmount, int Quantity, decimal PricePerUnit, decimal ExtendedAmount);
            }
            catch (Exception v)
            {
                Response.Write(v.Message);
            }
            return(service);
        }
Exemple #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataTable dt = null;

            try
            {
                IOrganizationService service = connection_to_crm();
                dt = EDUsys.GetUsers(service, 1, "");


                if (dt.Rows.Count > 0)
                {
                    //check whether login is perfect or not......or else check with getusers()
                    //EDUsys.GetUsers(service,1,"");
                    Session["username"] = TextBox1.Text;
                    Session["password"] = TextBox2.Text;
                    try
                    {
                        if (Request.QueryString["query1"] != null) //verify login for new shipping address V1
                        {
                            string query1 = Request.QueryString["query1"];
                            string que2   = Request.QueryString["que2"];
                            string que3   = Request.QueryString["que2"];

                            Response.Redirect("new_ship_edit.aspx?" + query1 + "&que2=" + que2 + "&que3=" + que3 + "&nat=AQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQ");
                        }
                        else if (Request.QueryString["query2"] != null) // checking while fill update oppurtunity
                        {
                            string query2  = Request.QueryString["query2"];
                            string version = Request.QueryString["query"];
                            Response.Redirect("Update_oppurtunity.aspx?" + query2 + "&query=" + version);
                        }
                        else if (Request.QueryString["query3"] != null) // checking in edit time
                        {
                            string query3 = Request.QueryString["query3"];
                            string option = Request.QueryString["option"];
                            Response.Redirect("Edit-Category-Item.asp?" + query3 + "&opt=" + option);
                        }
                        else if (Request.QueryString["query4"] != null) ////verify login for new shipping address V2,V3
                        {
                            string query4 = Request.QueryString["query4"];
                            string que2   = Request.QueryString["que2"];
                            string que3   = Request.QueryString["que2"];
                            string qid    = Request.QueryString["qid"];
                            Response.Redirect("new_ship_edit.aspx?" + query4 + "&qid=" + qid + "&que2=" + que2 + "&que3=" + que3 + "&nat=AQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQ");
                        }

                        else
                        {
                            Response.Redirect("home.asp");
                        }
                    }
                    catch (Exception k)
                    {
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "hello", "<script>alert('CRM Login is incorrect,please try again')</script>");
                }
            }
            catch (Exception k)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "hello", "<script>alert('CRM Login is incorrect,please try again')</script>");
            }
        }