public IActionResult Call(int CustomerId)
        {
            if (!isLoggedIn)
            {
                return(RedirectToAction("Index", "Home"));
            }

            CustomerCall existingCall = db.CustomerCalls
                                        .FirstOrDefault(Call => Call.CustomerId == CustomerId && (int)uid == Call.UserId);

            if (existingCall == null)
            {
                CustomerCall Call = new CustomerCall()
                {
                    CustomerId = CustomerId,
                    UserId     = (int)uid
                };

                db.CustomerCalls.Add(Call);
            }
            else
            {
                db.CustomerCalls.Remove(existingCall);
            }

            db.SaveChanges();
            return(RedirectToAction("Success"));
        }
Exemplo n.º 2
0
        void menuItem1_Click(object sender, EventArgs e)
        {
            //throw new Exception("The method or operation is not implemented.");
            frmCallsAssignUser oFrm = new frmCallsAssignUser();

            User      oUser = new User();
            DataTable dt    = oUser.GetActiveUsers();

            foreach (DataRow row in dt.Rows)
            {
                oFrm.cbUsers.Items.Add(row["User"].ToString());
            }
            oFrm.ShowDialog();

            if (oFrm.PressedButton == "Apply" && oFrm.UserSelected.Trim() != "")
            {
                CustomerCall oCall = new CustomerCall(this.CompanyID);
                foreach (Row row in this.table.TableModel.Selections.SelectedItems)
                {
                    //MessageBox.Show(row.Cells[0].Text);

                    if (oCall.Find(row.Cells[0].Text))
                    {
                        oCall.FindCall(row.Cells[0].Text);
                        oCall.UserID = oFrm.UserSelected;
                        oCall.Save();
                    }
                }
                frmCallsAssignment_Load(null, null);
            }
        }
Exemplo n.º 3
0
        public override InfoControl.Web.Auditing.Event LogErrorInDatabase(Exception ex)
        {
            var         eventEntity = base.LogErrorInDatabase(ex);
            HttpContext context     = HttpContext.Current;

            if (context != null && context.Session != null)
            {
                using (var customerManager = new CustomerManager(null))
                    using (var companyManager = new CompanyManager(null))
                        using (var membershipManager = new MembershipManager(null))
                        {
                            Company hostCompany = companyManager.GetHostCompany();
                            Company company     = companyManager.GetCompanyByContext(context);

                            Customer customer = customerManager.GetCustomerByLegalEntityProfile(hostCompany.CompanyId, company.LegalEntityProfileId);

                            if (customer != null)
                            {
                                var customerCall = new CustomerCall();
                                customerCall.EventId = eventEntity.EventId;

                                customerCall.Subject = (ex.Message.Length > 100 ? ex.Message.Substring(0, 90) + " ..." : ex.Message);

                                customerCall.CallNumber  = Util.GenerateUniqueID();
                                customerCall.CompanyId   = hostCompany.CompanyId;
                                customerCall.CustomerId  = customer.CustomerId;
                                customerCall.OpenedDate  = customerCall.ModifiedDate = DateTime.Now.Date;
                                customerCall.Description = String.Empty;

                                customerCall.CustomerCallTypeId   = CustomerCallType.ERROR;
                                customerCall.CustomerCallStatusId = CustomerCallStatus.New;
                                customerCall.Rating = 5;

                                customerCall.CallNumberAssociated = context.Request.RawUrl;
                                customerCall.Sector = Convert.ToString(context.Session["_lastPageTitle"]);

                                if (context.User != null)
                                {
                                    if (context.User.Identity != null)
                                    {
                                        if (context.User.Identity.IsAuthenticated)
                                        {
                                            User user = membershipManager.GetUserByEmail(context.User.Identity.Name);
                                            if (user != null)
                                            {
                                                customerCall.UserId = user.UserId;
                                            }
                                        }
                                    }
                                }

                                customerManager.InsertCustomerCall(customerCall, null, null, null);
                            }
                        }
            }
            return(eventEntity);
        }
Exemplo n.º 4
0
        void genreEditor_EndEdit(object sender, XPTable.Events.CellEditEventArgs e)
        {
            CustomerCall oCall = new CustomerCall(this.CompanyID);
            Row          row   = this.table.TableModel.Rows[e.Row];

            if (oCall.Find(row.Cells[0].Text))
            {
                oCall.FindCall(row.Cells[0].Text);
                oCall.UserID = ((ComboBoxCellEditor)e.Editor).SelectedItem.ToString();
                oCall.Save();
                //MessageBox.Show(row.Cells[4].Text);
            }
            //throw new Exception("The method or operation is not implemented.");
        }
        public override InfoControl.Web.Auditing.Event LogErrorInDatabase(Exception ex)
        {

            var eventEntity = base.LogErrorInDatabase(ex);
            HttpContext context = HttpContext.Current;

            if (context != null && context.Session != null)
                using (var customerManager = new CustomerManager(null))
                using (var companyManager = new CompanyManager(null))
                using (var membershipManager = new MembershipManager(null))
                {
                    Company hostCompany = companyManager.GetHostCompany();
                    Company company = companyManager.GetCompanyByContext(context);

                    Customer customer = customerManager.GetCustomerByLegalEntityProfile(hostCompany.CompanyId, company.LegalEntityProfileId);

                    if (customer != null)
                    {
                        var customerCall = new CustomerCall();
                        customerCall.EventId = eventEntity.EventId;

                        customerCall.Subject = (ex.Message.Length > 100 ? ex.Message.Substring(0, 90) + " ..." : ex.Message);

                        customerCall.CallNumber = Util.GenerateUniqueID();
                        customerCall.CompanyId = hostCompany.CompanyId;
                        customerCall.CustomerId = customer.CustomerId;
                        customerCall.OpenedDate = customerCall.ModifiedDate = DateTime.Now.Date;
                        customerCall.Description = String.Empty;

                        customerCall.CustomerCallTypeId = CustomerCallType.ERROR;
                        customerCall.CustomerCallStatusId = CustomerCallStatus.New;
                        customerCall.Rating = 5;

                        customerCall.CallNumberAssociated = context.Request.RawUrl;
                        customerCall.Sector = Convert.ToString(context.Session["_lastPageTitle"]);

                        if (context.User != null)
                            if (context.User.Identity != null)
                                if (context.User.Identity.IsAuthenticated)
                                {
                                    User user = membershipManager.GetUserByEmail(context.User.Identity.Name);
                                    if (user != null)
                                        customerCall.UserId = user.UserId;
                                }

                        customerManager.InsertCustomerCall(customerCall, null, null, null);
                    }
                }
            return eventEntity;
        }
Exemplo n.º 6
0
        private void SaveCalls()
        {
            CustomerCall oCall = new CustomerCall(this.CompanyID);

            foreach (Row row in this.table.TableModel.Rows)
            {
                if (oCall.Find(row.Cells[0].Text))
                {
                    oCall.FindCall(row.Cells[0].Text);
                    oCall.UserID = row.Cells[4].Text;
                    oCall.Save();
                    //MessageBox.Show(row.Cells[4].Text);
                }
            }
        }
Exemplo n.º 7
0
 private void table_KeyUp(object sender, KeyEventArgs e)
 {
     if (sender == table)
     {
         if (e.KeyCode == Keys.Delete)
         {
             CustomerCall oCall = new CustomerCall(this.CompanyID);
             Row          row   = this.table.TableModel.Selections.SelectedItems[0];
             if (oCall.Find(row.Cells[0].Text))
             {
                 oCall.FindCall(row.Cells[0].Text);
                 oCall.UserID = "";
                 oCall.Delete();
                 row.Cells[4].Text = "";
                 //MessageBox.Show(row.Cells[4].Text);
             }
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// This method displays customer, representant and employee informations in screen
        /// </summary>
        /// <param name="customerCall"></param>
        private void ShowCustomerCallInformations(CustomerCall customerCall)
        {
            pnlRepresentantName.Visible = pnlTechnicalEmployeeName.Visible = false;
            pnlCustomerName.Visible     = true;

            Page.ViewState["customerCallId"] = customerCall.CustomerCallId;

            litCustomer.Text = customerCall.Customer.Name;

            if (customerCall.RepresentantId.HasValue)
            {
                pnlRepresentantName.Visible = true;
                litRepresentant.Text        = customerCall.Representant.Profile != null ? customerCall.Representant.Profile.Name : customerCall.Representant.LegalEntityProfile.CompanyName;
            }

            if (customerCall.TechnicalEmployeeId.HasValue)
            {
                pnlTechnicalEmployeeName.Visible = true;
                litTechnicalEmployee.Text        = customerCall.Employee.Profile.Name;
            }
        }
        private void LoadCalls()
        {
            CustomerCall oCustCall = new CustomerCall(oCustomer.CompanyID);

            this.table.TableModel = new TableModel();
            //XPListViewItem itm;

            foreach (DataRow row in dt.Rows)
            {
                oCustomer.Find(row["CustomerID"].ToString());
                oCustCall.FindCall(oCustomer.ID);
                this.table.TableModel.Rows.Add(new Row(new Cell[] { new Cell(row["CustomerID"].ToString()),
                                                                    new Cell(oCustomer.Name),
                                                                    new Cell(oMySql.SqlDate(oCustomer.EndDate)),
                                                                    new Cell(oMySql.SqlDate(oCustomer.PickUpDate)),
                                                                    new Cell(oCustCall.UserID),
                                                                    new Cell(false), })
                                               );
            }
            //this.table.TableModel.RowHeight += 3;
        }
        /// <summary>
        /// This method displays customer, representant and employee informations in screen
        /// </summary>
        /// <param name="customerCall"></param>
        private void ShowCustomerCallInformations(CustomerCall customerCall)
        {
            pnlRepresentantName.Visible = pnlTechnicalEmployeeName.Visible = false;
            pnlCustomerName.Visible = true;

            Page.ViewState["customerCallId"] = customerCall.CustomerCallId;

            litCustomer.Text = customerCall.Customer.Name;

            if (customerCall.RepresentantId.HasValue)
            {
                pnlRepresentantName.Visible = true;
                litRepresentant.Text = customerCall.Representant.Profile != null ? customerCall.Representant.Profile.Name : customerCall.Representant.LegalEntityProfile.CompanyName;
            }

            if (customerCall.TechnicalEmployeeId.HasValue)
            {
                pnlTechnicalEmployeeName.Visible = true;
                litTechnicalEmployee.Text = customerCall.Employee.Profile.Name;                
            }
        }
        public IActionResult CallCreate(int CustomerId)
        {
            if (!isLoggedIn)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid == false)
            {
                // Send back to the page with the form to show errors.
                return(View("New"));
            }
            // ModelState IS valid...
            CustomerCall newCall = new CustomerCall()
            {
                UserId     = (int)uid,
                CustomerId = CustomerId
            };

            db.CustomerCalls.Add(newCall);
            db.SaveChanges();
            return(RedirectToAction("Success"));
        }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Request["ServiceOrderId"]))
        {
            serviceOrderId = Convert.ToInt32(Request["ServiceOrderId"]);
        }

        if (!IsPostBack)
        {
            ServiceItemsList = null;
            ProductItemsList = null;

            if (Convert.ToBoolean(Request["ReadOnly"]))
            {
                DisableControlsForPopUpView();
            }

            chkServiceType.DataBind();
            pnlTestType.Visible = chkServiceType.Items.Count > 0;

            chklstEquipmentDamage.DataBind();
            pnlEquipmentDamage.Visible = chklstEquipmentDamage.Items.Count > 0;

            chklstProductDamage.DataBind();
            pnlProductDamage.Visible = chklstProductDamage.Items.Count > 0;

            chkServiceType.DataBind();
            pnlServiceType.Visible = chkServiceType.Items.Count > 0;

            chkProductType.DataBind();
            pnlProductType.Visible = chkProductType.Items.Count > 0;

            chkInstallType.DataBind();
            pnlInstallType.Visible = chkInstallType.Items.Count > 0;

            chkHaltType.DataBind();
            pnlHaltType.Visible = chkHaltType.Items.Count > 0;

            chklstTests.DataBind();
            pnlTestType.Visible = chklstTests.Items.Count > 0;

            txtServiceOrderNumber.Text = Util.GenerateUniqueID();

            pnlCustomerContracts.Attributes["style"] = "display:none;";
            pnlCustomerCalls.Attributes["style"]     = "display:none;";
            updPanelEquipment.Attributes["style"]    = "display:none;";

            //verify the existence of ServiceOrder
            if (!String.IsNullOrEmpty(Request["ServiceOrderId"]))
            {
                btnShowAppointments.OnClientClick = "top.$.lightbox('Appointments.aspx?ServiceOrderId=" + Request["ServiceOrderId"] + "&lightbox[iframe]=true'); return false;";

                btnGenerateReceipt.Visible = true;

                //bind Combobox
                cboServiceOrderType.DataBind();
                cboServiceOrderStatus.DataBind();

                //set ServiceOrderNumber
                txtServiceOrderNumber.Text = Original_ServiceOrder.ServiceOrderNumber;

                //set combobox
                if (cboServiceOrderType.Items.FindByValue(Convert.ToString(Original_ServiceOrder.ServiceOrderTypeId)) != null)
                {
                    cboServiceOrderType.SelectedValue = Convert.ToString(Original_ServiceOrder.ServiceOrderTypeId);
                }

                if (Original_ServiceOrder.ServiceOrderStatusId.HasValue)
                {
                    cboServiceOrderStatus.SelectedValue = Convert.ToString(Original_ServiceOrder.ServiceOrderStatusId);
                }

                if (Original_ServiceOrder.DepositId.HasValue)
                {
                    cboDeposit.SelectedValue = Convert.ToString(Original_ServiceOrder.DepositId);
                }

                if (Original_ServiceOrder.CustomerCallId.HasValue)
                {
                    LoadCustomerCallsFromCustomer(Original_ServiceOrder.Customer);

                    cboCustomerCalls.SelectedValue = Original_ServiceOrder.CustomerCallId.ToString();

                    pnlCustomerCalls.Attributes["style"] = "display:block";


                    if (Original_ServiceOrder.CustomerCall.CustomerEquipmentId.HasValue)
                    {
                        ShowCustomerEquipment(Original_ServiceOrder.CustomerCall.CustomerEquipment);
                    }
                }

                SelCustomer.ShowCustomer(Original_ServiceOrder.Customer);

                if (Original_ServiceOrder.CustomerEquipmentId.HasValue)
                {
                    ShowCustomerEquipment(Original_ServiceOrder.CustomerEquipment);
                }

                if (Original_ServiceOrder.ContractId.HasValue)
                {
                    cboCustomerContracts.SelectedValue = Original_ServiceOrder.ContractId.ToString();
                }

                lblCreatedDate.Text = "Data de Abertura:<br />" + Original_ServiceOrder.OpenedDate.ToString();

                //set the Gridview

                BindService();
                BindProducts();

                SetServiceOrderEquipmentDamage(Original_ServiceOrder.ServiceOrderEquipmentDamageId);
                SetServiceOrderProductDamage(Original_ServiceOrder.ServiceOrderProductDamageId);
                SetServiceTest(Original_ServiceOrder.ServiceOrderTestId);
                SetServiceOrderHaltType(Original_ServiceOrder.ServiceOrderHaltType);
                SetServiceOrderInstallType(Original_ServiceOrder.ServiceOrderInstallType);
                SetServiceOrderProductType(Original_ServiceOrder.ServiceOrderProductType);
                SetServiceOrderType(Original_ServiceOrder.ServiceType);

                //
                //Brings the comments associated to service order being loaded
                //
                ucComments.SubjectId = (int)serviceOrderId;
            } // load CustomerCall
            else if (Context.Items["CustomerCallId"] != null)
            {
                Page.ViewState["CustomerCallId"] = Context.Items["CustomerCallId"];
                CustomerCall customerCall = CustomerManager.GetCustomerCall(Convert.ToInt32(Context.Items["CustomerCallId"]));
                SelCustomer.ShowCustomer(customerCall.Customer);
                if (customerCall.CustomerEquipmentId.HasValue)
                {
                    cboCustomerEquipments.SelectedValue = customerCall.CustomerEquipmentId.ToString();
                }
            }
        }
        if (String.IsNullOrEmpty(Request["ServiceOrderId"]))
        {
            btnShowAppointments.Visible = false;
        }
    }
 private void SetCustomerCallPriority(CustomerCall entity)
 {
     if (entity.CustomerCallTypeId == CustomerCallType.ERROR)
         entity.Rating = 5;
 }
        /// <summary>
        /// this method insert a customerCall and insert a new appointment for a TechnicalEmployee
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="employeeId"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        public void InsertCustomerCall(CustomerCall entity, Int32? employeeId, DateTime? beginTime, DateTime? endTime)
        {
            if (!CheckCustomerCallFromCustomer(entity))
                return;

            if (entity.CustomerEquipmentId == 0)
                entity.CustomerEquipmentId = null;

            entity.CreatedDate = entity.ModifiedDate = DateTime.Now;
            entity.OpenedDate = DateTime.Now;

            if (!entity.CustomerCallStatusId.HasValue)
                entity.CustomerCallStatusId = CustomerCallStatus.New;

            SetCustomerCallPriority(entity);
            DbContext.CustomerCalls.InsertOnSubmit(entity);
            DbContext.SubmitChanges();
        }
        /// <summary>
        /// This method update one CustomerCall.
        /// </summary>
        /// <param name=entity>original_entity</param>
        /// <param name=entity>entity</param>
        public void UpdateCustomerCall(CustomerCall original_entity, CustomerCall entity)
        {
            if (original_entity.CustomerCallStatusId == CustomerCallStatus.Closed)
                entity.ClosedDate = DateTime.Now;

            if (!original_entity.TechnicalEmployeeId.HasValue && entity.TechnicalEmployeeId.HasValue &&
                original_entity.UserId.HasValue)
            {
                var manager = new AlertManager(this);
                Employee employee = new HumanResourcesManager(this).GetEmployee(entity.CompanyId,
                                                                                (int)entity.TechnicalEmployeeId);

                manager.InsertAlert(entity.UserId.Value,
                                    "Olá " + original_entity.User.Profile.FirstName + ", prazer!<br /> Meu nome é " +
                                    employee.Profile.AbreviatedName +
                                    " e sou o responsável pelo seu chamado, que está em análise!");
            }

            SetCustomerCallPriority(entity);
            original_entity.CopyPropertiesFrom(entity);
            original_entity.ModifiedDate = DateTime.Now;
            DbContext.SubmitChanges();
        }
 /// <summary>
 /// This method delete one CustomerCall.
 /// </summary>
 /// <param name=entity>entity</param>
 public void DeleteCustomerCall(CustomerCall entity)
 {
     DbContext.CustomerCalls.DeleteOnSubmit(entity);
     DbContext.SubmitChanges();
 }
        /// <summary>
        /// This method verifies if a customer is generating the same customerCall
        /// return false if exist the same customerCall  
        /// </summary>
        public bool CheckCustomerCallFromCustomer(CustomerCall entity)
        {
            CustomerCall customerCall =
                DbContext.CustomerCalls.Where(x => x.CustomerId == entity.CustomerId &&
                                                   x.Subject == entity.Subject &&
                                                   x.CallNumberAssociated == entity.CallNumberAssociated).FirstOrDefault();

            if (customerCall == null)
                return true;

            if (customerCall.CustomerCallStatusId == CustomerCallStatus.New ||
                customerCall.CustomerCallStatusId == CustomerCallStatus.Waiting)
                return false;

            if (customerCall.CustomerCallStatusId == CustomerCallStatus.Closed)
            {
                customerCall.CustomerCallStatusId = CustomerCallStatus.New;
                customerCall.OpenedDate = DateTime.Now;
                DbContext.SubmitChanges(); 
            }

            return false;
        }
    private void SaveCustomerCall()
    {
        CustomerCall customerCall = new CustomerCall();
        CompanyManager companyManager = new CompanyManager(this);
        Comment comment = new Comment();

        Int32 tmp = 0;

        if (this.Page.ViewState["CustomerCallId"] == null)
            customerCall.UserId = User.Identity.UserId;

        if (Int32.TryParse(Convert.ToString(Page.ViewState["CustomerCallId"]), out tmp))
        {
            original_CustomerCall = CustomerManager.GetCustomerCall(Convert.ToInt32(Page.ViewState["CustomerCallId"]));
            customerCall.CopyPropertiesFrom(original_CustomerCall);
        }


        // if this page was opened in PopUp way, save this customerCall as Host's customerCall

        customerCall.CompanyId = Company.CompanyId;

        if (Page.ViewState["ModalPopUp"] == null)
            if (!Int32.TryParse(Convert.ToString(Page.ViewState["CustomerId"]), out tmp))
            {
                ShowError(Resources.Exception.UnselectedCustomer);
                return;
            }

        customerCall.CustomerId = Convert.ToInt32(Page.ViewState["CustomerId"]);

        if (Convert.ToInt32(Page.ViewState["ModalPopUp"]) == 1)
        {
            customerCall.CustomerId = CustomerManager.GetHostCustomerByLegalEntityProfileId(Company.LegalEntityProfileId).CustomerId;
            customerCall.CompanyId = HostCompany.CompanyId;
        }

        customerCall.RepresentantId = null;
        if (!String.IsNullOrEmpty(cboRepresentant.SelectedValue))
            customerCall.RepresentantId = Convert.ToInt32(cboRepresentant.SelectedValue);

        customerCall.Rating = rtnPriority.CurrentRating;
        customerCall.CustomerCallStatusId = Convert.ToInt32(cboCustomerCallStatus.SelectedValue);
        customerCall.CustomerCallTypeId = Convert.ToInt32(cboCustomerCallType.SelectedValue);
        customerCall.CallNumber = txtCallNumber.Text;
        customerCall.CallNumberAssociated = txtCallNumberAssociated.Text;

        customerCall.Sector = txtSector.Text;
        customerCall.Description = txtDescription.Value;
        customerCall.Subject = txtSubject.Text;

        if (!String.IsNullOrEmpty(cboTechnicalEmployee.SelectedValue))
            customerCall.TechnicalEmployeeId = Convert.ToInt32(cboTechnicalEmployee.SelectedValue);

        if (!String.IsNullOrEmpty(cboCustomerEquipments.SelectedValue))
            customerCall.CustomerEquipmentId = Convert.ToInt32(cboCustomerEquipments.SelectedValue);

        if (original_CustomerCall != null)
        {
            customerCall.ModifiedByUser = User.Identity.UserName;
            CustomerManager.UpdateCustomerCall(original_CustomerCall, customerCall);
        }
        else
        {
            customerCall.CreatedByUser = User.Identity.UserName;
            CustomerManager.InsertCustomerCall(customerCall, null, null, null);
            CommentsCustomerCall.SubjectId = customerCall.CustomerCallId;
        }
        Context.Items["CustomerCallId"] = customerCall.CustomerCallId;

        if (Page.ViewState["SO"] != null)
        {
            Server.Transfer("../Services/ServiceOrder.aspx");
            return;
        }

        if (Page.ViewState["ModalPopUp"] == null)
            Response.Redirect("CustomerCalls.aspx");
    }