private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!g_DaLoadDuLieu)
            {
                DoiTac objDoiTac  = new DoiTac();
                string MaNhanVien = "";
                if ((cboNhanVien.SelectedIndex != 0) && (cboNhanVien.SelectedIndex != -1))
                {
                    MaNhanVien = cboNhanVien.Items[cboNhanVien.SelectedIndex].DataRow.ToString();
                }

                List <DoiTac> lstDoiTac = new List <DoiTac> ();
                if (MaNhanVien.Length > 0)
                {
                    lstDoiTac = objDoiTac.GetListOfDoiTacs_ByNhanVien(MaNhanVien);
                }
                else
                {
                    lstDoiTac = objDoiTac.GetListOfDoiTacs();
                }

                g_lstBacCao_CuocGoiMoiGioi = new List <BacCao_CuocGoiMoiGioi>();
                int i = 0;
                foreach (DoiTac objDT in lstDoiTac)
                {
                    BacCao_CuocGoiMoiGioi objCGMG = TimKiem_BaoCao.GetBaoCao_CuocGoiMoiGioi(calTuNgay.Value, calDenNgay.Value, objDT);


                    if (objCGMG.SoChuyen >= intSoChuyen.Value)
                    {
                        g_lstBacCao_CuocGoiMoiGioi.Add(objCGMG);
                    }

                    i++;
                    m_fmProgress.lblDescription.Invoke(
                        (MethodInvoker) delegate()
                    {
                        m_fmProgress.lblDescription.Text = "Processing ... " + objDT.Name;
                        m_fmProgress.progressBar.Value   = Convert.ToInt32(i * (100.0 / lstDoiTac.Count));
                    }
                        );
                    if (m_fmProgress.Cancel)
                    {
                        // Set the e.Cancel flag so that the WorkerCompleted event
                        // knows that the process was canceled.
                        e.Cancel = true;
                        return;
                    }
                }
            }
            else
            {
                gridDienThoai.DataMember = "ListDienThoai";
                gridDienThoai.SetDataBinding(LocDuLieu(g_lstBacCao_CuocGoiMoiGioi, g_MaNhanVien, g_SoChuyen), "ListDienThoai");
            }
        }
Example #2
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            DoiTac objDoiTac  = new DoiTac();
            string MaNhanVien = "";

            if ((cboNhanVien.SelectedIndex != 0) && (cboNhanVien.SelectedIndex != -1))
            {
                MaNhanVien = cboNhanVien.SelectedItem.Value.ToString();
            }

            List <DoiTac> lstDoiTac = new List <DoiTac> ();

            if (MaNhanVien.Length > 0)
            {
                lstDoiTac = objDoiTac.GetListOfDoiTacs_ByNhanVien(MaNhanVien);
            }
            else
            {
                lstDoiTac = objDoiTac.GetListOfDoiTacs();
            }

            int      iDays      = 0;
            DateTime timeServer = DieuHanhTaxi.GetTimeServer();

            if ((calTuNgay.Value.Month == timeServer.Month) && (calTuNgay.Value.Year == timeServer.Year))
            {
                iDays = timeServer.Day;
            }
            else
            {
                iDays = StringTools.GetDayOfMonth(calTuNgay.Value.Year, calTuNgay.Value.Month);
            }

            DataTable dtDoiTacTheoNgay = CreateTableBaoCao8(iDays);

            int    i         = 0;
            string strYYYYMM = string.Format("{0:yyyy-MM}", calTuNgay.Value);

            foreach (DoiTac objDT in lstDoiTac)
            {
                DataRow dr = dtDoiTacTheoNgay.NewRow();
                dr["MaMoiGioi"]   = objDT.MaDoiTac;
                dr["DiaChi"]      = objDT.Address;
                dr["DienThoais"]  = objDT.Phones;
                dr["TenNhanVien"] = objDT.TenNhanVien;
                int    iTongXe = 0; int iSoChuyen = 0;
                string strDay = "";
                for (int iDay = 1; iDay <= iDays; iDay++)
                {
                    strDay    = strYYYYMM + "-" + StringTools.GeDayString(iDay);
                    iSoChuyen = TimKiem_BaoCao.GetSoChuyenCuocGoiMoiGioiInOneDay(strDay, objDT);
                    dr["Ngay" + iDay.ToString()] = iSoChuyen.ToString();
                    iTongXe += iSoChuyen; iSoChuyen = 0;
                }
                dr["SoChuyen"] = iTongXe.ToString();
                if (iTongXe > (int)intSoChuyen.Value)
                {
                    dtDoiTacTheoNgay.Rows.Add(dr);
                }
                i++;
                m_fmProgress.lblDescription.Invoke(
                    (MethodInvoker) delegate()
                {
                    m_fmProgress.lblDescription.Text = "Processing ... " + objDT.Name;
                    m_fmProgress.progressBar1.Value  = Convert.ToInt32(i * (100.0 / lstDoiTac.Count));
                }
                    );
                if (m_fmProgress.Cancel)
                {
                    // Set the e.Cancel flag so that the WorkerCompleted event
                    // knows that the process was canceled.
                    e.Cancel = true;
                    return;
                }
            }
            gridDienThoai.DataMember = "ListDienThoai";
            gridDienThoai.SetDataBinding(dtDoiTacTheoNgay, "ListDienThoai");
            if (iDays < 31)
            {
                for (int t = iDays + 1; t <= 31; t++)
                {
                    gridDienThoai.RootTable.Columns["Ngay" + t.ToString()].Visible = false;
                }
            }
        }