Exemplo n.º 1
0
        public override void PopulateData()
        {
            if (dtpFromDate.Value != null && dtpFromDate.Value.Value.Year == 1753)
            {
                dtpFromDate.Value = null;
            }

            if (dtpTillDate.Value != null && dtpTillDate.Value.Value.Year == 1753)
            {
                dtpTillDate.Value = null;
            }

            DateTime?fromDate = dtpFromDate.Value.ToDateorNull();
            DateTime?tillDate = dtpTillDate.Value.ToDateorNull();

            string phone = txtPhone.Text.Trim();
            string name  = ddlCustomer.Text.Trim().ToLower();

            string line = txtLine.Text.Trim();
            string stn  = txtSTN.Text.Trim();

            bool MissedCalls = optMissedCalls.Checked;

            string SubCompanyNo = string.Empty;

            int SubCompanyId = ddlSubCompanyId.SelectedValue.ToInt();

            if (SubCompanyId > 0)
            {
                using (TaxiDataContext dbX = new TaxiDataContext())
                {
                    SubCompanyNo = dbX.Gen_SubCompanies.FirstOrDefault(c => c.Id == SubCompanyId).ConnectionString;
                }


                if (string.IsNullOrEmpty(SubCompanyNo))
                {
                    grdCalls.Rows.Clear();;
                    MessageBox.Show("Sub Company CallerId Number is not defined");
                    return;
                    //  SubCompanyNo = null;
                }
            }
            else
            {
                SubCompanyNo = string.Empty;
            }



            TaxiDataContext db = new TaxiDataContext();

            var list = (from a in db.CallHistories
                        join b in db.Gen_SubCompanies on a.CalledToNumber equals b.ConnectionString into table2
                        from b in table2.DefaultIfEmpty()

                        where (fromDate == null || a.CallDateTime.Value.Date >= fromDate) &&
                        (tillDate == null || a.CallDateTime.Value.Date <= tillDate) &&
                        (name == string.Empty || a.Name.Trim().ToLower() == name) &&
                        (MissedCalls == false || (a.STN == null || a.STN == "")) &&
                        (phone == string.Empty || a.PhoneNumber.Trim() == phone) &&
                        (line == string.Empty || (a.Line != null && a.Line.Trim() == line)) &&
                        (stn == string.Empty || (a.STN != null && a.STN.Trim() == stn)) &&
                        (IsAccepted == true || (a.IsAccepted != null && a.IsAccepted == true)) &&
                        (SubCompanyNo == string.Empty || (a.CalledToNumber != null && a.CalledToNumber.Trim() == SubCompanyNo))
                        orderby a.CallDateTime descending
                        select new
            {
                Sno = a.Sno,
                Name = a.Name,
                PhoneNumber = a.PhoneNumber,
                CallDateTime = a.CallDateTime,
                Line = a.Line,
                STN = a.STN,
                Duration = a.CallDuration,
                IsMissed = (a.IsAccepted != null && a.IsAccepted == true) ? "1" : "0",
                Company = b != null && b.CompanyName != "" ? b.CompanyName : a.CalledToNumber
            }).ToList();

            //foreach (var item in list)
            //{
            //    //objTempCallHistory.Add(new TempCallHistory { Name = item.Name, PhoneNo = item.PhoneNumber, CallDateTime = item.CallDateTime, STN = item.STN, Line = item.Line, CompanyName = item.Company });
            //}

            db.Dispose();



            //var list2 = (from a in General.GetQueryable<CallHistory>(null)
            //            where (fromDate == null || a.CallDateTime.Value.Date >= fromDate)
            //             && (tillDate == null || a.CallDateTime.Value.Date <= tillDate)
            //             && (name == string.Empty || a.Name.ToStr().Trim().ToLower() == name)
            //             && (phone == string.Empty || a.PhoneNumber.Trim() == phone)
            //              && (line == string.Empty || (a.Line != null && a.Line.Trim() == line))
            //               && (stn == string.Empty || (a.STN != null && a.STN.Trim() == stn))
            //               && (IsAccepted == true || (a.IsAccepted != null && a.IsAccepted == true))
            //            orderby a.CallDateTime descending
            //            select new
            //            {
            //                Sno = a.Sno,
            //                Name = a.Name,
            //                PhoneNumber = a.PhoneNumber,
            //                CallDateTime = a.CallDateTime,
            //                Line = a.Line,
            //                STN = a.STN,
            //                Duration = a.CallDuration,
            //                IsMissed = (a.IsAccepted != null && a.IsAccepted == true) ? "1" : "0"
            //            }).ToList();

            lblTotalAnsweredCalls.Text = "Total Answered Calls : " + list.Where(c => c.STN.Length > 0).Count();
            lblTotalMissedCalls.Text   = "Total Missed Calls : " + list.Where(c => (c.STN == null || c.STN == "")).Count();
            lblTotalBookings.Text      = "Total Bookings : " + 0;
            grdCalls.DataSource        = list;



            if (this.objCLISettings.IsAnalog.ToBool())
            {
                grdCalls.Columns["Line"].IsVisible     = true;
                grdCalls.Columns["Line"].Width         = 50;
                grdCalls.Columns["CallDateTime"].Width = 160;
                grdCalls.Columns["Name"].Width         = 140;
            }

            else
            {
                grdCalls.Columns["Line"].IsVisible     = false;
                grdCalls.Columns["CallDateTime"].Width = 180;
                grdCalls.Columns["Name"].Width         = 140;
            }


            if (this.objCLISettings.DigitalCLIType.ToInt() == 2)
            {
                grdCalls.Columns["Line"].IsVisible     = true;
                grdCalls.Columns["Line"].Width         = 40;
                grdCalls.Columns["CallDateTime"].Width = 160;
                grdCalls.Columns["Name"].Width         = 140;

                grdCalls.Columns["Duration"].Width = 120;


                if (IsDataLoaded == false)
                {
                    this.Width = this.Width + 190;
                }


                //  btnMissedCalls.Visible = true;
            }
            else
            {
                grdCalls.Columns["Sno"].IsVisible      = false;
                grdCalls.Columns["STN"].IsVisible      = false;
                grdCalls.Columns["Duration"].IsVisible = false;
            }



            if (this.objCLISettings.VOIPCLIType.ToInt() == 2 || this.objCLISettings.VOIPCLIType.ToInt() == 4)
            {
                grdCalls.Columns["Line"].IsVisible      = true;
                grdCalls.Columns["Duration"].IsVisible  = false;
                grdCalls.Columns["Recording"].IsVisible = true;
            }

            grdCalls.Columns["Sno"].Width              = 60;
            grdCalls.Columns["CompanyName"].Width      = 140;
            grdCalls.Columns["CompanyName"].HeaderText = "Company";
            grdCalls.Columns["STN"].IsVisible          = true;
            grdCalls.Columns["PhoneNumber"].Width      = 120;
            grdCalls.Columns["PhoneNumber"].HeaderText = "Phone Number";

            (grdCalls.Columns["CallDateTime"] as GridViewDateTimeColumn).CustomFormat = "dd/MM/yyyy";
            grdCalls.Columns["CallDateTime"].HeaderText = "Call Date Time";

            grdCalls.Columns["IsMissed"].IsVisible = false;



            if (grdCalls.Columns["IsMissed"].ConditionalFormattingObjectList.Count == 0)
            {
                ConditionalFormattingObject objMissedCondition = new ConditionalFormattingObject();
                objMissedCondition.TValue1       = "1";
                objMissedCondition.ApplyToRow    = true;
                objMissedCondition.RowBackColor  = Color.LightPink;
                objMissedCondition.ConditionType = ConditionTypes.Equal;

                grdCalls.Columns["IsMissed"].ConditionalFormattingObjectList.Add(objMissedCondition);
            }


            if (this.objCLISettings != null && this.objCLISettings.VOIPCLIType.ToInt() == 4 && File.Exists(Application.StartupPath + "\\CabTreasureEmeraldCallRecording.exe"))
            {
                btnMissedCalls.Visible = true;
            }

            IsDataLoaded = true;
        }
Exemplo n.º 2
0
        private void Login()
        {
            try
            {
                TaxiDataContext db = new TaxiDataContext();

                UM_User obj = db.UM_Users.FirstOrDefault(c => (c.IsActive == true) && (c.UserName.ToLower() == txtUserName.Text.Trim().ToLower() && c.Passwrd.ToLower() == txtPassword.Text.Trim().ToLower()));


                if (obj == null)
                {
                    RadMessageBox.Show("Invalid UserName or Password.", "EuroSoftTech", MessageBoxButtons.OK, RadMessageIcon.Error);
                    txtUserName.Focus();
                    db.Dispose();
                    return;
                }
                else
                {
                    AppVars.objSubCompany = db.Gen_SubCompanies.FirstOrDefault(c => c.Id == obj.SubcompanyId);

                    if (AppVars.objSubCompany == null)
                    {
                        db.Dispose();

                        ENUtils.ShowMessage("This user is not created properly" + Environment.NewLine
                                            + "Define Subcompany for that user in Users Menu.");
                        return;
                    }


                    AppVars.DefaultSubCompanyId = AppVars.objSubCompany.Id;
                }

                if (this.InvokeRequired)
                {
                    DisplayProgressBar d = new DisplayProgressBar(ShowLoadingImage);
                    this.BeginInvoke(d);
                }
                else
                {
                    ShowLoadingImage();
                }


                frmMainMenu frm = new frmMainMenu();


                if (IsAutoLogin)
                {
                    frm.showWarning = false;
                }

                frm.ObjLoginUser        = new DAL.LoginUser();
                frm.ObjLoginUser.SysGen = obj.UM_SecurityGroup.SysGen.ToBool();

                frm.ObjLoginUser.LgroupId  = obj.SecurityGroupId.ToInt();
                frm.ObjLoginUser.LoginName = obj.UserName;
                frm.ObjLoginUser.LuserId   = obj.Id;
                frm.ObjLoginUser.UserName  = obj.UserName;
                frm.ObjLoginUser.Email     = obj.Email;
                frm.ObjLoginUser.Password  = obj.Passwrd;

                frm.ObjLoginUser.LsessionId = db.stp_ControlerLogins(frm.ObjLoginUser.LuserId.ToInt(), null, null, Environment.MachineName).FirstOrDefault().Id.ToInt();



                frm.ObjLoginUser.IsAdmin = obj.ConfirmPasswrd.ToStr() == "1"?true:false;
                AppVars.LoginObj         = frm.ObjLoginUser;


                AppVars.AppTheme    = obj.ThemeName;
                frm.CurrentTheme    = obj.ThemeName;
                frm.ShowAllBookings = obj.ShowAllBookings.ToBool();

                frm.ShowAllDrivers = obj.ShowAllDrivers.ToBool();

                frm.ShowDriverFilter    = obj.ShowDriverFilter.ToBool();
                frm.ShowBookingFilter   = obj.ShowBookingFilter.ToBool();
                AppVars.ShowAllBookings = obj.ShowAllBookings.ToBool();
                AppVars.CanTransferJob  = obj.TransferBooking.ToBool();

                AppVars.IsTelephonist = obj.Fax.ToStr() == "1" ? true : false;

                frm.Show();



                this.ShowInTaskbar = false;

                this.Hide();

                frmLoading.Close();

                db.Dispose();



                // Close();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }