コード例 #1
0
        protected void Save_Click(object sender, EventArgs e)
        {
            int result = 0;


            foreach (GridViewRow dr in grddata.Rows)
            {
                foreach (TableCell c in dr.Cells)
                {
                    if (c.Text == " ")
                    {
                        c.Text = "";
                    }
                }

                string[] date_time         = (dr.Cells[1].Text).Split('-');
                string   CustomerNm        = dr.Cells[2].Text + " " + dr.Cells[3].Text;
                string   CellPh            = dr.Cells[4].Text;
                string   AltPh             = dr.Cells[5].Text;
                string   HomePh            = dr.Cells[6].Text;
                string   Email             = dr.Cells[7].Text;
                string   Address           = dr.Cells[8].Text;
                string[] CityStateZip      = dr.Cells[9].Text.Split(',');
                string   followupstatus    = dr.Cells[10].Text;
                string   followupdate      = dr.Cells[11].Text;
                string   Productofinterest = dr.Cells[12].Text;
                string   Besttimeofcontact = dr.Cells[13].Text;
                string   meetingstatus     = dr.Cells[14].Text;
                string   CallTakenBy       = dr.Cells[15].Text;
                string   Notes             = dr.Cells[16].Text;
                string   primarycontact    = dr.Cells[17].Text;
                string   ContactPreference = dr.Cells[18].Text;
                string   BillingAddress    = dr.Cells[19].Text;
                string   JobLocation       = dr.Cells[20].Text;
                string   LeadType          = dr.Cells[21].Text;
                string   AssignedTo        = dr.Cells[22].Text;
                string   Reasonofclose     = dr.Cells[23].Text;

                Customer objcust = new Customer();
                objcust.missingcontacts = 0;

                if (CellPh == "0" || CellPh == "")
                {
                    objcust.missingcontacts++;
                }
                if (AltPh == "0" || AltPh == "")
                {
                    objcust.missingcontacts++;
                }
                if (HomePh == "0" || HomePh == "")
                {
                    objcust.missingcontacts++;
                }


                if (objcust.missingcontacts > 2)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('Please Fill atleast one contact(Cell Phone, Home Phone or Alt. Phone');", true);
                    return;
                }

                int primarycont = new_customerBLL.Instance.Searchprimarycontact(HomePh, CellPh, AltPh, 0);
                if (primarycont == 1)
                {
                    objcust.Isrepeated = false;
                }
                else
                {
                    objcust.Isrepeated = true;
                }

                objcust.EstDate         = (date_time != null) ? date_time[0].ToString() : "1/1/1753";
                objcust.EstTime         = (date_time != null) ? date_time[1].ToString() : "";
                objcust.customerNm      = CustomerNm;
                objcust.CellPh          = CellPh;
                objcust.AltPh           = AltPh;
                objcust.HousePh         = HomePh;
                objcust.Email           = Email;
                objcust.CustomerAddress = Address;
                objcust.City            = CityStateZip[0].ToString();
                objcust.state           = CityStateZip[1].ToString();
                objcust.Zipcode         = CityStateZip[2].ToString();
                objcust.followupdate    = followupdate != "" ? followupdate : "1/1/1753";
                int productId = UserBLL.Instance.GetProductIDByProductName(Productofinterest);
                objcust.Productofinterest = productId;
                objcust.BestTimetocontact = Besttimeofcontact;
                objcust.status            = meetingstatus;
                objcust.CallTakenby       = CallTakenBy;
                objcust.Notes             = Notes;
                objcust.PrimaryContact    = primarycontact;
                objcust.ContactPreference = ContactPreference;
                if (BillingAddress == "same")
                {
                    objcust.BillingAddress = objcust.CustomerAddress + "," + objcust.City + "," + objcust.state + "," + objcust.Zipcode;
                }
                objcust.JobLocation = JobLocation;
                objcust.Leadtype    = CallTakenBy;
                objcust.Addedby     = CallTakenBy;
                objcust.CallTakenby = CallTakenBy;

                objcust.Map1 = objcust.customerNm + "-" + Guid.NewGuid().ToString().Substring(0, 5) + ".Jpeg";
                objcust.Map2 = objcust.customerNm + "-" + "Direction" + Guid.NewGuid().ToString().Substring(0, 5) + ".Jpeg";
                string DestinationPath = Server.MapPath("~/CustomerDocs/Maps/");
                new_customerBLL.Instance.SaveMapImage(objcust.Map1, objcust.CustomerAddress, objcust.City, objcust.state, objcust.Zipcode, DestinationPath);
                new_customerBLL.Instance.SaveMapImageDirection(objcust.Map2, objcust.CustomerAddress, objcust.City, objcust.state, objcust.Zipcode, DestinationPath);


                result = new_customerBLL.Instance.AddCustomer(objcust);

                if (primarycontact == "Cell Phone")
                {
                }

                string date = Convert.ToDateTime(objcust.EstDate).ToShortDateString();
                string datetime;


                if (date != "1/1/1753")
                {
                    datetime = Convert.ToDateTime(date + " " + objcust.EstTime).ToString("MM/dd/yy hh:mm tt");
                }
                else
                {
                    datetime = Convert.ToDateTime(objcust.followupdate).ToString("MM/dd/yy hh:mm tt");
                }

                if (result > 0)
                {
                    string AdminId   = ConfigurationManager.AppSettings["AdminUserId"].ToString();
                    string Adminuser = ConfigurationManager.AppSettings["AdminCalendarUser"].ToString();
                    string AdminPwd  = ConfigurationManager.AppSettings["AdminCalendarPwd"].ToString();
                    if (meetingstatus == "Set")
                    {
                        string gtitle   = objcust.EstTime + " -" + primarycontact + " -" + objcust.CallTakenby;
                        string gcontent = "Name: " + objcust.customerNm + " ,Product of Interest: " + Productofinterest + ", Phone: " + objcust.CellPh + ", Alt. phone: " + objcust.AltPh + ", Email: " + objcust.Email + ",Notes: " + objcust.Notes + ",Status: " + objcust.status;
                        string gaddress = objcust.CustomerAddress + " " + objcust.City + "," + objcust.state + "," + objcust.Zipcode;

                        if (CallTakenBy != AdminId)
                        {
                            GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), result.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), CallTakenBy);
                        }
                        GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), result.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), AdminId);

                        gtitle   = objcust.EstTime + " -" + primarycontact + " -" + Session["loginid"].ToString();
                        gcontent = "Name: " + objcust.customerNm + " , Cell Phone: " + objcust.CellPh + ", Alt. phone: " + objcust.AltPh + ", Email: " + objcust.Email + ",Service: " + objcust.Notes + ",Status: " + objcust.status;
                        gaddress = Address + " " + objcust.City + "," + objcust.state + " -" + objcust.Zipcode;
                        GoogleCalendarEvent.AddEvent(GoogleCalendarEvent.GetService("GoogleCalendar", Adminuser, AdminPwd), result.ToString(), gtitle, gcontent, gaddress, Convert.ToDateTime(datetime), Convert.ToDateTime(datetime).AddHours(1), JGConstant.CustomerCalendar);
                    }

                    AdminBLL.Instance.UpdateStatus(result, meetingstatus, objcust.followupdate);
                    int userId = Convert.ToInt16(Session[JG_Prospect.Common.SessionKey.Key.UserId.ToString()].ToString());
                    new_customerBLL.Instance.AddCustomerFollowUp(result, Convert.ToDateTime(objcust.followupdate), meetingstatus, userId, false, 0, "");

                    lblmsg.Visible  = true;
                    lblmsg.CssClass = "success";
                    lblmsg.Text     = "Data has been saved successfully";
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('Data has been saved successfully');", true);
                }
                else
                {
                    lblmsg.Visible  = true;
                    lblmsg.CssClass = "error";
                    lblmsg.Text     = "There is some error in adding the Prospect";
                }
            }
        }
コード例 #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");
        }