コード例 #1
0
        // protected void btnsave_Click(object sender, EventArgs e)
        protected void AutoSave(object sender, EventArgs e, string control)
        {
            try
            {
                //Button btnsave = sender as Button;
                //GridViewRow gr = (GridViewRow)btnsave.Parent.Parent;
                GridViewRow gr = null;
                if (control == JGConstant.DROPDOWNLIST)
                {
                    DropDownList ddlmeetingstatus = sender as DropDownList;
                    gr = (GridViewRow)ddlmeetingstatus.Parent.Parent;
                }
                else if (control == JGConstant.TEXTBOX)
                {
                    TextBox txtfollow = sender as TextBox;
                    gr = (GridViewRow)txtfollow.Parent.Parent;
                }
                LinkButton   lnkid           = (LinkButton)gr.FindControl("lnkestimateid");
                DropDownList ddlstatus       = (DropDownList)gr.FindControl("ddlmeetingstatus");
                TextBox      txtfollowup     = (TextBox)gr.FindControl("txtfollowup");
                HiddenField  hdffollowupdate = (HiddenField)gr.FindControl("hdffollowupdate");
                string       AdminId         = ConfigurationManager.AppSettings["AdminUserId"].ToString();
                DateTime     followupdate    = (txtfollowup.Text != "") ? Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE) : DateTime.MinValue;
                string       followDate      = string.IsNullOrEmpty(txtfollowup.Text) ? "1/1/1753" : Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE).ToString("MM/dd/yyyy");
                string       newstatus       = ddlstatus.SelectedItem.Text;
                if (newstatus == "Set")
                {
                    followDate = "1/1/1753";
                    AdminBLL.Instance.UpdateStatus(Convert.ToInt32(lnkid.Text), newstatus, followDate);
                    //Server.Transfer("~/Prospectmaster.aspx?title=" + lnkid.Text);
                    Session[SessionKey.Key.PreviousPage.ToString()] = JGConstant.PAGE_STATIC_REPORT;
                    Response.Redirect("~/Prospectmaster.aspx?title=" + lnkid.Text);
                }
                else if (newstatus == "Follow up")
                {
                    txtfollowup.Visible = true;
                    //if (hdffollowupdate.Value != "")
                    //{
                    //    followupdate = Convert.ToDateTime(hdffollowupdate.Value, JGConstant.CULTURE);
                    //    txtfollowup.Text = hdffollowupdate.Value;

                    //}
                    //else
                    //{
                    //    txtfollowup.Text = "";
                    //    followupdate = DateTime.MinValue;
                    //}
                    if (txtfollowup.Text == "")
                    {
                        followupdate     = Convert.ToDateTime(hdffollowupdate.Value, JGConstant.CULTURE);
                        txtfollowup.Text = hdffollowupdate.Value;
                        followDate       = string.IsNullOrEmpty(txtfollowup.Text) ? "1/1/1753" : Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE).ToString("MM/dd/yyyy");
                    }
                    UserBLL.Instance.updateProspectstatus(Convert.ToInt32(lnkid.Text), newstatus, followupdate);
                    GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, AdminId);
                    GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, JGConstant.CustomerCalendar);
                    if (LoginSession != AdminId)
                    {
                        GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, LoginSession);
                    }
                }
                else if (newstatus == "Prospect" || newstatus == "Rehash" || newstatus == "cancelation-no rehash")
                {
                    GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, AdminId);
                    GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, JGConstant.CustomerCalendar);
                    if (LoginSession != AdminId)
                    {
                        GoogleCalendarEvent.DeleteEvent(lnkid.Text, "", "", "", DateTime.Now, DateTime.Now, LoginSession);
                    }
                }
                else
                {
                    txtfollowup.Visible = false;
                }
                AdminBLL.Instance.UpdateStatus(Convert.ToInt32(lnkid.Text), newstatus, followDate);
                int userId = Convert.ToInt16(Session[JG_Prospect.Common.SessionKey.Key.UserId.ToString()].ToString());
                new_customerBLL.Instance.AddCustomerFollowUp(Convert.ToInt32(lnkid.Text), Convert.ToDateTime(followupdate), newstatus, userId, false, 0);
                // ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('Saved Successfully');", true);
                bindgrid("onload");
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('There is some error in Saving');", true);
            }
        }
コード例 #2
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            Button       btnsave          = sender as Button;
            GridViewRow  gr               = (GridViewRow)btnsave.Parent.Parent;
            LinkButton   lnkid            = (LinkButton)gr.FindControl("lnkcustomerid");
            DropDownList ddlstatus        = (DropDownList)gr.FindControl("ddlmeetingstatus");
            TextBox      txtfollowup      = (TextBox)gr.FindControl("txtfollowup");
            HiddenField  hdffollowupdate  = (HiddenField)gr.FindControl("hdffollowupdate");
            HiddenField  hdfmeetingstatus = (HiddenField)gr.FindControl("hdfmeetingstatus");
            string       followupdate     = string.IsNullOrEmpty(txtfollowup.Text) ? "1/1/1753" : Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE).ToString("MM/dd/yyyy");
            string       type             = lnkid.Text.Substring(0, 1);
            string       id               = lnkid.Text.Substring(1);
            int          custid           = Convert.ToInt32(id);
            string       oldstatus        = hdfmeetingstatus.Value;
            string       newstatus        = ddlstatus.SelectedValue;
            bool         updateresult     = false;
            string       AdminId          = ConfigurationManager.AppSettings["AdminUserId"].ToString();
            string       Adminuser        = ConfigurationManager.AppSettings["AdminCalendarUser"].ToString();
            string       AdminPwd         = ConfigurationManager.AppSettings["AdminCalendarPwd"].ToString();

            Customer c = new Customer();

            c = new_customerBLL.Instance.fetchcustomer(custid);
            string productName = UserBLL.Instance.GetProductNameByProductId(c.Productofinterest);

            if (newstatus == "Set")
            {
                if (type == "C")
                {
                    Response.Redirect("~/Sr_App/Customer_Profile.aspx?title=" + id);
                }
                else if (type == "P")
                {
                    Response.Redirect("~/Prospectmaster.aspx?title=" + id);
                }
            }

            //commented for phase I, Applicable in phase II

            //else if ((oldstatus == "Prospect" || oldstatus == "Follow up" || oldstatus == "Rehash" || oldstatus == "cancelation-no rehash") && (newstatus == "PTW est" || newstatus == "est>$1000" || newstatus == "est<$1000" || newstatus == "EST-one legger" || newstatus == "sold>$1000" || newstatus == "sold<$1000" || newstatus == "Closed (not sold)" || newstatus == "Closed (sold)"))
            //{
            //    ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('Cannot change prospect to estimate or sold');", true);
            //    return;
            //}
            else if (newstatus == "Prospect" || newstatus == "Follow up" || newstatus == "Rehash" || newstatus == "cancelation-no rehash")
            {
                if (AdminId != c.Addedby)
                {
                    GoogleCalendarEvent.DeleteEvent(id, "", "", "", DateTime.Now, DateTime.Now, c.Addedby);
                }
                GoogleCalendarEvent.DeleteEvent(id, "", "", "", DateTime.Now, DateTime.Now, AdminId);
                GoogleCalendarEvent.DeleteEvent(id, "", "", "", DateTime.Now, DateTime.Now, JGConstant.CustomerCalendar);
            }
            else if (newstatus == "PTW est" || newstatus == "est>$1000" || newstatus == "est<$1000" || newstatus == "EST-one legger" || newstatus == "Closed (not sold)" || newstatus == "sold>$1000" || newstatus == "sold<$1000")
            {
                string gtitle   = c.EstTime + " -" + c.PrimaryContact + " -" + c.Addedby;
                string gcontent = "Name: " + c.customerNm + " , Product of Interest: " + productName + ", Phone: " + c.CellPh + ", Alt. phone: " + c.AltPh + ", Email: " + c.Email + ",Notes: " + c.Notes + ",Status: " + newstatus;
                string gaddress = c.CustomerAddress + "," + c.City;
                string datetime = null;
                if (c.EstDate != "1/1/1753")
                {
                    datetime = Convert.ToDateTime(c.EstDate + " " + c.EstTime).ToString("MM/dd/yy hh:mm tt");
                }
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), AdminId);
                GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), AdminId);
                if (AdminId != c.Addedby)
                {
                    GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), c.Addedby);
                    GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), c.Addedby);
                }
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), JGConstant.CustomerCalendar);
                GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), JGConstant.CustomerCalendar);
            }

            //commented for phase I, Applicable in phase II

            //else if (newstatus == "sold>$1000" || newstatus == "sold<$1000")
            //{
            //    Session["CustomerId"] = custid;
            //    Session["CustomerName"] = c.customerNm;
            //    Response.Redirect("~/Sr_App/ProductEstimate.aspx");
            //}

            try
            {
                updateresult = AdminBLL.Instance.UpdateStatus(custid, newstatus, followupdate);
                int userId = Convert.ToInt16(Session[JG_Prospect.Common.SessionKey.Key.UserId.ToString()]);
                new_customerBLL.Instance.AddCustomerFollowUp(custid, Convert.ToDateTime(followupdate), newstatus, userId, false, 0, "");
            }

            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('" + ex.Message + "');", true);
            }
            //bindgrid();
        }
コード例 #3
0
        // protected void btnsave_Click(object sender, EventArgs e)
        protected void AutoSave(object sender, EventArgs e, string control)
        {
            // Button btnsave = sender as Button;
            GridViewRow gr = null;

            if (control == JGConstant.DROPDOWNLIST)
            {
                DropDownList ddlmeetingstatus = sender as DropDownList;
                gr = (GridViewRow)ddlmeetingstatus.Parent.Parent;
            }
            else if (control == JGConstant.TEXTBOX)
            {
                TextBox txtfollow = sender as TextBox;
                gr = (GridViewRow)txtfollow.Parent.Parent;
            }
            //GridViewRow gr = (GridViewRow)btnsave.Parent.Parent;
            LinkButton   lnkid           = (LinkButton)gr.FindControl("lnkcustomerid");
            TextBox      txtfollowup     = (TextBox)gr.FindControl("txtfollowup");
            HiddenField  hdffollowupdate = (HiddenField)gr.FindControl("hdffollowupdate");
            DropDownList ddlstatus       = (DropDownList)gr.FindControl("ddlmeetingstatus");
            DateTime     followupdate    = (txtfollowup.Text != "") ? Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE) : DateTime.Now.AddDays(7);
            string       followDate      = string.IsNullOrEmpty(txtfollowup.Text) ? DateTime.Now.AddDays(7).ToString("MM/dd/yyyy") : Convert.ToDateTime(txtfollowup.Text, JGConstant.CULTURE).ToString("MM/dd/yyyy");
            int          custid          = Convert.ToInt32(lnkid.Text);
            string       newstatus       = ddlstatus.SelectedItem.Text;
            string       AdminId         = ConfigurationManager.AppSettings["AdminUserId"].ToString();
            string       Adminuser       = ConfigurationManager.AppSettings["AdminCalendarUser"].ToString();
            string       AdminPwd        = ConfigurationManager.AppSettings["AdminCalendarPwd"].ToString();
            Customer     c = new Customer();

            c = new_customerBLL.Instance.fetchcustomer(custid);
            string productName = UserBLL.Instance.GetProductNameByProductId(c.Productofinterest);

            if (ddlstatus.SelectedValue == "Set")
            {
                Response.Redirect("~/Sr_App/Customer_Profile.aspx?title=" + lnkid.Text);
            }
            else if (newstatus == "Rehash" || newstatus == "cancelation-no rehash")
            {
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), "", "", "", DateTime.Now, DateTime.Now, AdminId);
                if (AdminId != c.Addedby)
                {
                    GoogleCalendarEvent.DeleteEvent(custid.ToString(), "", "", "", DateTime.Now, DateTime.Now, c.Addedby);
                }
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), "", "", "", DateTime.Now, DateTime.Now, JGConstant.CustomerCalendar);
            }
            if (newstatus == "est>$1000" || newstatus == "est<$1000")
            {
                string gtitle   = c.EstTime + " -" + c.PrimaryContact + " -" + c.Addedby;
                string gcontent = "Name: " + c.customerNm + " , Product of Interest: " + productName + ", Phone: " + c.CellPh + ", Alt. phone: " + c.AltPh + ", Email: " + c.Email + ",Notes: " + c.Notes + ",Status: " + newstatus;
                string gaddress = c.CustomerAddress + "," + c.City;
                string datetime = null;
                if (c.EstDate != "1/1/1753")
                {
                    if (c.EstDate != "")
                    {
                        if (c.EstDate != null)
                        {
                            datetime = Convert.ToDateTime(c.EstDate + " " + c.EstTime).ToString("MM/dd/yy hh:mm tt");
                        }
                    }
                }
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), AdminId);
                GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), AdminId);
                if (AdminId != c.Addedby)
                {
                    GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), c.Addedby);
                    GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), c.Addedby);
                }
                GoogleCalendarEvent.DeleteEvent(custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), JGConstant.CustomerCalendar);
                GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), custid.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime, JGConstant.CULTURE), Convert.ToDateTime(datetime, JGConstant.CULTURE).AddHours(1), JGConstant.CustomerCalendar);
            }

            else if (newstatus == "sold>$1000" || newstatus == "sold<$1000")
            {
                Session["CustomerId"]   = custid;
                Session["CustomerName"] = c.customerNm;
                Response.Redirect("~/Sr_App/ProductEstimate.aspx");
            }
            else if (newstatus == "Closed (not sold)")
            {
                // save reason of closed
            }

            //foreach (ListItem item in ddlstatus.Items)
            //{
            //    ListItem i = ddlstatus.Items.FindByValue(item.Value);
            //    if (i.Text == "est>$1000" || i.Text == "est<$1000" || i.Text == "sold>$1000" || i.Text == "sold<$1000")
            //    {
            //        i.Attributes.Add("style", "color:gray;");
            //        i.Attributes.Add("disabled", "true");
            //        i.Value = "-1";
            //    }
            //}
            int userId = Convert.ToInt16(Session[JG_Prospect.Common.SessionKey.Key.UserId.ToString()].ToString());

            AdminBLL.Instance.UpdateStatus(custid, ddlstatus.SelectedItem.Text, followDate);
            new_customerBLL.Instance.AddCustomerFollowUp(custid, Convert.ToDateTime(followupdate), ddlstatus.SelectedItem.Text, userId, false, 0);
            bindgrid("onload");
        }