public WorldInfo[] GetAllWorlds()
        {
            _db.Open();

            List<WorldInfo> worlds = new List<WorldInfo>();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLWORLDS_STOREDPROC, System.Data.CommandType.StoredProcedure, null);

            int ordinalId = reader.GetOrdinal(DbNames.WORLDINFO_ID);
            int ordinalName = reader.GetOrdinal(DbNames.WORLDINFO_NAME);
            int ordinalDesc = reader.GetOrdinal(DbNames.WORLDINFO_DESC);
            int ordinalIP = reader.GetOrdinal(DbNames.WORLDINFO_IP);
            int ordinalPort = reader.GetOrdinal(DbNames.WORLDINFO_PORT);

            while (reader.Read())
            {
                WorldInfo world = new WorldInfo
                {
                    WorldId = reader.GetInt32(ordinalId),
                    WorldName = reader.GetString(ordinalName),
                    WorldDesc = reader.GetString(ordinalDesc),
                    IPAddress = reader.GetString(ordinalIP),
                    Port = reader.GetInt32(ordinalPort)
                };

                worlds.Add(world);
            }

            reader.Close();
            _db.Close();

            return worlds.ToArray();
        }
        public ChannelInfo[] GetAllChannels()
        {
            _db.Open();

            List<ChannelInfo> channels = new List<ChannelInfo>();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLCHANNELS_STOREDPROC, System.Data.CommandType.StoredProcedure, null);

            int ordinalId = reader.GetOrdinal(DbNames.CHANNELINFO_ID);
            int ordinalName = reader.GetOrdinal(DbNames.CHANNELINFO_NAME);
            int ordinalDesc = reader.GetOrdinal(DbNames.CHANNELINFO_DESC);
            int ordinalIP = reader.GetOrdinal(DbNames.CHANNELINFO_IP);
            int ordinalPort = reader.GetOrdinal(DbNames.CHANNELINFO_PORT);
            int ordinalPK = reader.GetOrdinal(DbNames.CHANNELINFO_PK);
            while (reader.Read())
            {
                ChannelInfo channel = new ChannelInfo
                {
                    ChannelId = reader.GetInt32(ordinalId),
                    ChannelName = reader.GetString(ordinalName),
                    ChannelDesc = reader.GetString(ordinalDesc),
                    IPAddress = reader.GetString(ordinalIP),
                    Port = reader.GetInt32(ordinalPort),
                    PK = reader.GetBoolean(ordinalPK)
                };

                channels.Add(channel);
            }

            reader.Close();
            _db.Close();

            return channels.ToArray();
        }
 public frmQuanLyMaVach(List<ThongTinMaVach> dsThongTinMaVach)
 {
     InitializeComponent();
     IniForm();
     //Gán dữ liệu
     dgvHangHoa.DataSource = dsThongTinMaVach.ToArray();
     FixDatagridview();
 }
        public void CheckDataGridCongSL(DataGridView dgv, string maKho)
        {
            if (dgv.RowCount != 0)
            {
                try
                {

                    Server_Client.Client cl = new Server_Client.Client();
                    this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                    clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
                    Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                    kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
                    List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>();
                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        bool retVal = false;
                        foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                        {
                            if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()) && maKho.Equals(item.Makho))
                            {
                                retVal = true;
                                break;
                            }
                        }
                        if (!retVal)
                        {
                            Entities.ChiTietKhoHangTheoHoaHonNhap ct = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                            ct.Hanhdong = "Insert";
                            ct.Mahanghoa = dgv["MaHangHoa", i].Value.ToString();
                            ct.Makho = maKho;
                            ct.Ngaynhap = DateServer.Date();
                            DateTime ngayHetHan = DateTime.Now;
                            if (dgv["NgayHetHan", i] != null)
                                ngayHetHan = (DateTime)dgv["NgayHetHan", i].Value;
                            ct.Ngayhethan = ngayHetHan;
                            ct.Soluong = int.Parse(dgv["SoLuong", i].Value.ToString());
                            ct.Ghichu = "";
                            ctList.Add(ct);
                        }
                    }
                    Server_Client.Client cl1 = new Server_Client.Client();
                    this.client1 = cl1.Connect(Luu.IP, Luu.Ports);
                    clientstrem = cl1.SerializeObj(this.client1, "ThemChiTietKhoHang", ctList.ToArray());
                }
                catch (Exception)
                {

                }
            }
        }
Exemple #5
0
        private static void Main()
        {
            var startTime = DateTime.Now;
            var settings = new Settings();
            var helper = new Helper(settings);            
            var tasks = new List<Task<ImageDetails>>();

            // Get the ID's
            var imageIds = GetImageIds();

            // Create the Tasks
            
            foreach (var imageId in imageIds)
            {
                var task = new Task<ImageDetails>(() => AcquireImage(new ImageServiceClient(), imageId).Result);
                task.Start();
                tasks.Add(task);
            }

            // wait for the tasks
            Task.WaitAll(tasks.ToArray());

            // write out the files
            using (var writer = helper.GetOutputWriter())
            {
                writer.WriteLine(Image.GetHeaderString());
              
                foreach (var task in tasks)
                {
                    helper.WriteImageFile(task.Result.ImageBytes, task.Result.Metadata.FileName);
                    writer.WriteLine(task.Result.Metadata);
                }
            }

            Console.WriteLine("{0} images processed.", tasks.Count);
            Console.WriteLine("Creating zip file.");

            helper.WriteZipFile();
            helper.Cleanup();

            Console.WriteLine("Done.");

            var elapsed = DateTime.Now - startTime;
            Console.WriteLine("Elapsed time: {0}", elapsed);
#if DEBUG
            Console.Write("<Enter> to quit.");
            Console.ReadLine();
#endif
        }
        public CascadingDropDownNameValue[] GetAmandamentTemplates(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<AmandamentTemplateEntity> list = new AmandamentTemplateMapper().ListWithAdvancedFilter("", StatusEnum.Active);
            foreach (AmandamentTemplateEntity entity in list)
            {
                CascadingDropDownNameValue cdnv;

                cdnv = new CascadingDropDownNameValue(entity.Title, entity.AmandamentTemplateId.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        public CascadingDropDownNameValue[] GetBanks(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<BankEntity> list = new BankMapper().ListWithAdvancedFilter("", StatusEnum.Active);
            foreach (BankEntity ent in list)
            {
                CascadingDropDownNameValue cdnv;

                if (ent.Title == contextKey)
                {
                    cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString(), true);
                }
                else
                {
                    cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString());
                }
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        private void txtTimKiem_TextChanged(object sender, EventArgs e)
        {
            if (rdbTen.Checked == true)
            {

                if (ctBCXH_Search == null)
                {
                    BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0];
                    dtgvhienthi.DataSource = tkkt;
                    FixDatagridview();

                    tsslchitiet.Enabled = false;
                    tsslExcel.Enabled = false;
                    tsslPdf.Enabled = false;
                    tsslWord.Enabled = false;
                }
                else
                    if (ctBCXH_Search != null)
                    {
                        if (txtTimKiem.Text.Length == 0)
                        {
                            BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0];
                            dtgvhienthi.DataSource = tkkt;
                            FixDatagridview();

                            tsslchitiet.Enabled = false;
                            tsslExcel.Enabled = false;
                            tsslPdf.Enabled = false;
                            tsslWord.Enabled = false;
                        }
                        else
                        {
                            int ctBCXH_Search_count = 0;

                            for (int i = 0; i < ctBCXH_Search.Length; i++)
                            {
                                int index = -1;
                                index = ctBCXH_Search[i].TenNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower());
                                if (index >= 0)
                                {
                                    ctBCXH_Search_count++;
                                }
                            }
                            BCXuatHangTheoNhomHang[] ctBCXH_Search1 = new BCXuatHangTheoNhomHang[ctBCXH_Search_count];
                            ctBCXH_Search_count = 0;

                            for (int i = 0; i < ctBCXH_Search.Length; i++)
                            {
                                int index = -1;
                                index = ctBCXH_Search[i].TenNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower());
                                if (index >= 0)
                                {
                                    ctBCXH_Search1[ctBCXH_Search_count] = ctBCXH_Search[i];
                                    ctBCXH_Search_count++;
                                }
                            }
                            if (ctBCXH_Search_count == 0)
                            {
                                tsslchitiet.Enabled = false;
                                tsslExcel.Enabled = false;
                                tsslPdf.Enabled = false;
                                tsslWord.Enabled = false;
                            }
                            else
                            {
                                tsslchitiet.Enabled = true;
                                tsslExcel.Enabled = true;
                                tsslPdf.Enabled = true;
                                tsslWord.Enabled = true;
                            }
                            ///////////////////////////////MRK FIX
                            List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>();
                            double tong0 = 0;
                            foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search1)
                            {
                                tong0 += item.TongSoLuongXuat;
                                tem0.Add(item);
                            }
                            Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang();
                            tem1.TenNhomHang = "Tổng: ";
                            tem1.TongSoLuongXuat = (int)tong0;
                            tem0.Add(tem1);
                            //////////////////////////////////////
                            dtgvhienthi.DataSource = tem0.ToArray();
                            //dtgvhienthi.DataSource = ctBCXH_Search1;
                            FixDatagridview();
                        }
                    }
            }
            else
                if (rdbMa.Checked == true)
                {
                    if (ctBCXH_Search == null)
                    {
                        BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0];
                        dtgvhienthi.DataSource = tkkt;
                        FixDatagridview();

                        tsslchitiet.Enabled = false;
                        tsslExcel.Enabled = false;
                        tsslPdf.Enabled = false;
                        tsslWord.Enabled = false;

                    }
                    else
                        if (ctBCXH_Search != null)
                        {
                            if (txtTimKiem.Text.Length == 0)
                            {
                                BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0];
                                dtgvhienthi.DataSource = tkkt;
                                FixDatagridview();

                                tsslchitiet.Enabled = false;
                                tsslExcel.Enabled = false;
                                tsslPdf.Enabled = false;
                                tsslWord.Enabled = false;

                            }
                            else
                            {
                                int ctBCXH_Search_count = 0;

                                for (int i = 0; i < ctBCXH_Search.Length; i++)
                                {
                                    int index = -1;
                                    index = ctBCXH_Search[i].MaNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower());
                                    if (index >= 0)
                                    {
                                        ctBCXH_Search_count++;
                                    }
                                }
                                BCXuatHangTheoNhomHang[] ctBCXH_Search1 = new BCXuatHangTheoNhomHang[ctBCXH_Search_count];
                                ctBCXH_Search_count = 0;

                                for (int i = 0; i < ctBCXH_Search.Length; i++)
                                {
                                    int index = -1;
                                    index = ctBCXH_Search[i].MaNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower());
                                    if (index >= 0)
                                    {
                                        ctBCXH_Search1[ctBCXH_Search_count] = ctBCXH_Search[i];
                                        ctBCXH_Search_count++;
                                    }
                                }
                                if (ctBCXH_Search_count == 0)
                                {
                                    tsslchitiet.Enabled = false;
                                    tsslExcel.Enabled = false;
                                    tsslPdf.Enabled = false;
                                    tsslWord.Enabled = false;
                                }
                                else
                                {
                                    tsslchitiet.Enabled = true;
                                    tsslExcel.Enabled = true;
                                    tsslPdf.Enabled = true;
                                    tsslWord.Enabled = true;
                                }
                                ///////////////////////////////MRK FIX
                                List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>();
                                double tong0 = 0;
                                foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search1)
                                {
                                    tong0 += item.TongSoLuongXuat;
                                    tem0.Add(item);
                                }
                                Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang();
                                tem1.TenNhomHang = "Tổng: ";
                                tem1.TongSoLuongXuat = (int)tong0;
                                tem0.Add(tem1);
                                //////////////////////////////////////
                                dtgvhienthi.DataSource = tem0.ToArray();
                                //dtgvhienthi.DataSource = ctBCXH_Search1;
                                FixDatagridview();
                            }
                        }
                }
        }
        private void btnhienthi_Click(object sender, EventArgs e)
        {
            if (KiemTra())
            {
                LayNhomHang();
                LayNgay();
                LayHangHoa();
                GoiHang();
                ChiTietGoiHang();
                LayHDBanHang();
                LayChiTiet_HDBanHang();
                LayPhieuDieuChuyenKhoNoiBo();
                LayChiTiet_PhieuDieuChuyenKho();
                LayPhieuXuatHuy();
                LayChiTiet_XuatHuy();
                LayTraLaiNCC();
                LayChiTiet_TraLaiNCC();
                LayChiTiet_HangHoaXuat();

                ArrTongHangXuat();
                ///////////////////////////////MRK FIX
                List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>();
                double tong0 = 0;
                foreach (Entities.BCXuatHangTheoNhomHang item in ArrBCXH)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    tong0 += item.TongSoLuongXuat;
                    tem0.Add(item);
                }
                Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang();
                tem1.TenNhomHang = "Tổng: ";
                tem1.TongSoLuongXuat = (int)tong0;
                tem0.Add(tem1);
                //////////////////////////////////////
                //dtgvhienthi.DataSource = ArrBCXH;
                dtgvhienthi.DataSource = tem0.ToArray();
                FixDatagridview();
                ctBCXH_Search = ArrBCXH;
                if (ArrBCXH.Length > 0)
                {
                    tsslchitiet.Enabled = true;
                    tsslPdf.Enabled = true;
                    tsslExcel.Enabled = true;
                    tsslWord.Enabled = true;
                }
                else
                {
                    tsslchitiet.Enabled = false;
                    tsslPdf.Enabled = false;
                    tsslExcel.Enabled = false;
                    tsslWord.Enabled = false;
                }
            }
        }
Exemple #10
0
 monsterManager = new MonsterManager(conString, providerName);
        }

        public Map[] GetAllMaps()
        {
            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLMAPS_STOREDPROC, System.Data.CommandType.StoredProcedure, null);

            int ordinalId = reader.GetOrdinal(DbNames.MAP_ID);
            int ordinalName = reader.GetOrdinal(DbNames.MAP_NAME);
            int ordinalMultiplyValue = reader.GetOrdinal(DbNames.MAP_MULTIPLYVALUE);
            int ordinalSpawnX = reader.GetOrdinal(DbNames.MAP_SPAWNX);
            int ordinalSpawnY = reader.GetOrdinal(DbNames.MAP_SPAWNY);

            List<Map> maps = new List<Map>();

            while (reader.Read())
            {
                Map m = new Map()
                {
                    MapID = reader.GetInt32(ordinalId),
                    Name = reader.GetString(ordinalName),
                    MultiplyValue = reader.GetInt32(ordinalMultiplyValue),
                    SpawnX = reader.GetInt32(ordinalSpawnX),
                    SpawnY = reader.GetInt32(ordinalSpawnY)
                };

                maps.Add(m);
            }

            reader.Close();
            _db.Close();

            foreach (Map map in maps)
            {
                map.Portals = portalManager.GetPortalsByMapId(map.MapID);
                map.Npcs = npcManager.GetNpcsByMapId(map.MapID);
     map.Monsters = monsterManager.GetMonstersByMapId(map.MapID);
     if (map.MapID != 9 && map.MapID != 10 && map.MapID != 13 && map.MapID != 14) // maps we dont have maskes for yet..
         map.WalkableTiles = GetWalkableTiles(map.Name);
            }
            

            return maps.ToArray();
        }

        public Map GetMapById(int mapId)
        {
            DbParameter mapIdParameter = _db.CreateParameter(DbNames.GETMAPBYID_ID_PARAMETER, mapId);

            mapIdParameter.DbType = System.Data.DbType.Int32;

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETMAPBYID_STOREDPROC, System.Data.CommandType.StoredProcedure, mapIdParameter);

            int ordinalId = reader.GetOrdinal(DbNames.MAP_ID);
            int ordinalName = reader.GetOrdinal(DbNames.MAP_NAME);
            int ordinalMultiplyValue = reader.GetOrdinal(DbNames.MAP_MULTIPLYVALUE);
            int ordinalSpawnX = reader.GetOrdinal(DbNames.MAP_SPAWNX);
            int ordinalSpawnY = reader.GetOrdinal(DbNames.MAP_SPAWNY);

            Map m = null;

            while (reader.Read())
            {
                m = new Map
                {
                    MapID = reader.GetInt32(ordinalId),
                    Name = reader.GetString(ordinalName),
                    MultiplyValue = reader.GetInt32(ordinalMultiplyValue),
                    SpawnX = reader.GetInt32(ordinalSpawnX),
                    SpawnY = reader.GetInt32(ordinalSpawnY)
                };
            }

            reader.Close();
            _db.Close();

            m.Portals = portalManager.GetPortalsByMapId(mapId);
            m.Npcs = npcManager.GetNpcsByMapId(mapId);

            return m;
        }
 private void rdbTatCa_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbTatCa.Checked == true)
     {
         txtTimKiem.Text = "";
         if (ctBCXH_Search.Length > 0)
         {
             tsslchitiet.Enabled = true;
             tsslPdf.Enabled = true;
             tsslExcel.Enabled = true;
             tsslWord.Enabled = true;
         }
         else
         {
             tsslchitiet.Enabled = false;
             tsslPdf.Enabled = false;
             tsslExcel.Enabled = false;
             tsslWord.Enabled = false;
         }
         ///////////////////////////////MRK FIX
         List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>();
         double tong0 = 0;
         foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search)
         {
             tong0 += item.TongSoLuongXuat;
             tem0.Add(item);
         }
         Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang();
         tem1.TenNhomHang = "Tổng: ";
         tem1.TongSoLuongXuat = (int)tong0;
         tem0.Add(tem1);
         //////////////////////////////////////
         dtgvhienthi.DataSource = tem0.ToArray();
         //dtgvhienthi.DataSource = ctBCXH_Search;
         FixDatagridview();
     }
 }
        public CascadingDropDownNameValue[] GetOrganizationalUnits(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<OrganizationalUnitView> list = new OrganizationalUnitMapper().List("");
            foreach (OrganizationalUnitView ent in list)
            {
                CascadingDropDownNameValue cdnv;
                if (ent.TitleAndOrganizationaUnitGroup == contextKey)
                {
                    cdnv = new CascadingDropDownNameValue(ent.TitleAndOrganizationaUnitGroup, ent.Id.ToString(), true);
                }
                else
                {
                    cdnv = new CascadingDropDownNameValue(ent.TitleAndOrganizationaUnitGroup, ent.Id.ToString());
                }

                values.Add(cdnv);
            }

            return values.ToArray();
        }
        //true:SoQuy    False: CTSoQuy
        public frmBaoCaorpt(string LuaChon, Entities.SoQuy[] dulieu, string path, bool select)
        {
            try
            {
                InitializeComponent();
                CongTy();
                foreach (Entities.SoQuy item in dulieu)
                {
                    item.DuDauKy = item.DuDauKy.Replace(",", "");
                    item.PhatSinhNo = item.PhatSinhNo.Replace(",", "");
                    item.PhatSinhCo = item.PhatSinhCo.Replace(",", "");
                    item.DuCuoiKy = item.DuCuoiKy.Replace(",", "");
                }
                if (select)
                {
                    GUI.Report.rptBCSoQuy report = new GUI.Report.rptBCSoQuy();
                    List<Entities.BCSoQuy> dulieu1 = new List<Entities.BCSoQuy>();
                    foreach (Entities.SoQuy item in dulieu)
                    {
                        Entities.BCSoQuy tem = new Entities.BCSoQuy();
                        tem.MaTK = item.MaTK;
                        tem.TenTK = item.TenTK;
                        tem.DuDauKy = double.Parse(item.DuDauKy);
                        tem.PhatSinhNo = double.Parse(item.PhatSinhNo);
                        tem.PhatSinhCo = double.Parse(item.PhatSinhCo);
                        tem.DuCuoiKy = double.Parse(item.DuCuoiKy);
                        //tem.NgayLap = item.NgayLap;
                        //tem.MaPhieu = item.MaPhieu;
                        //tem.Ton = double.Parse(item.Ton);
                        dulieu1.Add(tem);
                    }
                    Entities.BCSoQuy[] view = dulieu1.ToArray();
                    report.SetDataSource(view);
                    crvReport.ReportSource = report;
                    report.SetParameterValue("TenCongTy", CT.TenCongTy);
                    report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                    report.SetParameterValue("DienThoai", CT.SoDienThoai);
                    report.SetParameterValue("Web", CT.Website);
                    report.SetParameterValue("Email", CT.Email);
                    report.SetParameterValue("FaxCongTy", CT.Fax);
                    report.SetParameterValue("TenBaoCao", "SỔ QUỸ");
                    report.SetParameterValue("NgayIn", DateServer.Date().ToString("dd/MM/yyyy"));
                    if (LuaChon.Equals("SoQuy_In"))
                    {
                        crvReport.Show();
                    }
                    else if (LuaChon.Equals("SoQuy_XLS"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.Excel);
                    }
                    else if (LuaChon.Equals("SoQuy_DOC"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.WordForWindows);
                    }
                    else if (LuaChon.Equals("SoQuy_PDF"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.PortableDocFormat);
                    }
                }
                else
                {
                    GUI.Report.rptBCChiTietSoQuy report = new GUI.Report.rptBCChiTietSoQuy();
                    List<Entities.BCSoQuy> dulieu1 = new List<Entities.BCSoQuy>();
                    foreach (Entities.SoQuy item in dulieu)
                    {
                        Entities.BCSoQuy tem = new Entities.BCSoQuy();
                        tem.MaTK = item.MaTK;
                        tem.TenTK = item.TenTK;
                        tem.DuDauKy = double.Parse(item.DuDauKy);
                        tem.PhatSinhNo = double.Parse(item.PhatSinhNo);
                        tem.PhatSinhCo = double.Parse(item.PhatSinhCo);
                        tem.DuCuoiKy = double.Parse(item.DuCuoiKy);
                        tem.NgayLap = item.NgayLap;
                        tem.MaPhieu = item.MaPhieu;
                        tem.Ton = double.Parse(item.Ton);
                        dulieu1.Add(tem);
                    }
                    Entities.BCSoQuy[] view = dulieu1.ToArray();
                    report.SetDataSource(view);
                    crvReport.ReportSource = report;
                    report.SetParameterValue("TenCongTy", CT.TenCongTy);
                    report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                    report.SetParameterValue("DienThoai", CT.SoDienThoai);
                    report.SetParameterValue("Web", CT.Website);
                    report.SetParameterValue("Email", CT.Email);
                    report.SetParameterValue("FaxCongTy", CT.Fax);
                    report.SetParameterValue("TenBaoCao", "CHI TIẾT SỔ QUỸ");
                    report.SetParameterValue("NgayIn", DateServer.Date().ToString("dd/MM/yyyy"));
                    if (LuaChon.Equals("SoQuy_In"))
                    {
                        crvReport.Show();
                    }
                    else if (LuaChon.Equals("SoQuy_XLS"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.Excel);
                    }
                    else if (LuaChon.Equals("SoQuy_DOC"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.WordForWindows);
                    }
                    else if (LuaChon.Equals("SoQuy_PDF"))
                    {
                        new GUI.Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.PortableDocFormat);
                    }
                }

            }
            catch { }
        }
 private void txtTimKiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         string Search = txtTimKiem.Text;
         List<Entities.HangHoa> ketqua = new List<Entities.HangHoa>();
         foreach (Entities.HangHoa item in MANG)
         {
             int test = -1;
             if (rdbMa.Checked)    //Tìm Kiếm Theo Mã
             {
                 test = item.MaHangHoa.ToLower().IndexOf(Search.ToLower());
             }
             else if (rdbTen.Checked)   //Tìm Kiếm Theo Tên
             {
                 test = item.TenHangHoa.ToLower().IndexOf(Search.ToLower());
             }
             if (test >= 0)
             {
                 ketqua.Add(item);
             }
         }
         dgvQuanLyHangHoa.DataSource = ketqua.ToArray();
     }
     catch { }
 }
        public void CheckDataGridCongSL1(DataGridView dgv, string maKho)
        {
            Server_Client.Client cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
            clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
            Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
            kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
            List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctKhoList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>();
            try
            {
                if (dgv.RowCount != 0)
                {

                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                        {
                            // lay cac hang hoa da ton tai
                            if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()))
                            {
                                Entities.ChiTietKhoHangTheoHoaHonNhap ct;
                                ct = new Entities.ChiTietKhoHangTheoHoaHonNhap("UpdateCong", maKho, dgv["MaHangHoa", i].Value.ToString(), int.Parse(dgv["SoLuong", i].Value.ToString()));
                                ctKhoList.Add(ct);
                                break;
                            }
                        }
                    }
                    TruSLMang(ctKhoList.ToArray());

                }
            }
            catch (Exception)
            {

            }
        }
        public string[] GetUsersList(string prefixText, int count)
        {
            List<string> results = new List<string>();

            PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
            UserPrincipal qbeUser = new UserPrincipal(ctx);
            qbeUser.DisplayName = "*" + prefixText + "*";
            PrincipalSearcher searcher = new PrincipalSearcher(qbeUser);
            foreach (var found in searcher.FindAll())
            {
                results.Add(found.SamAccountName);
            }

            return results.ToArray();
        }
        public CascadingDropDownNameValue[] GetLeaveTypes(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<LeaveTypeEntity> list = new LeaveTypeMapper().List("");
            foreach (LeaveTypeEntity entity in list)
            {
                CascadingDropDownNameValue cdnv;

                cdnv = new CascadingDropDownNameValue(entity.Title, entity.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        public CascadingDropDownNameValue[] GetStepsByGradeId(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            string gradeId;
            if (!kv.ContainsKey("Grade"))
            {
                return null;
            }
            gradeId = kv["Grade"];

            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<StepEntity> list = new StepMapper().ListByGradeId(gradeId);
            foreach (StepEntity ent in list)
            {
                string text = (ent.Id);
                CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(text, ent.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        public CascadingDropDownNameValue[] GetRoles(string knownCategoryValues, string category)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<RoleEntity> list = new RoleMapper().List("");
            foreach (RoleEntity ent in list)
            {
                CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        public CascadingDropDownNameValue[] GetPaymentTypesByLeaveType(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            int leaveTypelId;
            if (!kv.ContainsKey("LeaveTypes") ||
            !Int32.TryParse(kv["LeaveTypes"], out leaveTypelId))
            {
                return null;
            }

            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<LeaveTypeLevelEntity> list = new LeaveTypeLevelMapper().List(leaveTypelId);
            foreach (LeaveTypeLevelEntity ent in list)
            {
                CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.LeaveNameType.ToString(), ent.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        private void frmBCXuatHangTheoNhomHang_Load(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < cbbthang.Items.Count; i++)
                {
                    if (cbbthang.Items[i].ToString() == datesv.Month.ToString())
                    {
                        cbbthang.SelectedIndex = i;
                        break;
                    }
                }

                for (int i = 0; i < cbbnam.Items.Count; i++)
                {
                    if (cbbnam.Items[i].ToString() == datesv.Year.ToString())
                    {
                        cbbnam.SelectedIndex = i;
                        break;
                    }
                }

                LayNhomHang();
                //Entities.NhomHang[] K_nhomhang = this.NhomHang;
                LayNgay();
                DateTime K_BatDau = this.BatDau;
                DateTime K_KetThuc = this.KetThuc;
                GoiHang();
                ChiTietGoiHang();
                //Entities.GoiHang[] K_goihang = this.goihang;
                //Entities.ChiTietGoiHang[] K_chitietgoihang = this.chitietgoihang;
                LayHangHoa();
                //Entities.HangHoa[] K_hanghoa = this.HangHoa;
                LayHDBanHang();
                //Entities.HDBanHang[] K_HDBanHang = this.HDBanHang;
                LayChiTiet_HDBanHang();
                //Entities.ChiTietHDBanHang[] K_ctHDBanHang = this.ctHDBanHang;
                LayPhieuDieuChuyenKhoNoiBo();
                //Entities.PhieuDieuChuyenKhoNoiBo[] K_PDieuChuyen = this.PDieuChuyen;
                LayChiTiet_PhieuDieuChuyenKho();
                //Entities.ChiTietPhieuDieuChuyenKho[] K_ctPDCK = this.ctPDCK;
                LayPhieuXuatHuy();
                //Entities.PhieuXuatHuy[] K_PXuatHuy = this.PXuatHuy;
                LayChiTiet_XuatHuy();
                //Entities.ChiTietXuatHuy[] K_ctPXuatHuy = this.ctPXuatHuy;
                LayTraLaiNCC();
                //Entities.TraLaiNCC[] K_TraLaiNCC = this.TraLaiNCC;
                LayChiTiet_TraLaiNCC();
                //Entities.ChiTietTraLaiNhaCungCap[] K_ctTraLaiNCC = this.ctTraLaiNCC;
                LayChiTiet_HangHoaXuat();

                ArrTongHangXuat();
                ///////////////////////////////MRK FIX
                List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>();
                double tong0 = 0;
                foreach (Entities.BCXuatHangTheoNhomHang item in ArrBCXH)
                {
                    tong0 += item.TongSoLuongXuat;
                    tem0.Add(item);
                }
                Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang();
                tem1.TenNhomHang = "Tổng: ";
                tem1.TongSoLuongXuat = (int)tong0;
                tem0.Add(tem1);
                //////////////////////////////////////
                //dtgvhienthi.DataSource = ArrBCXH;
                dtgvhienthi.DataSource = tem0.ToArray();

                FixDatagridview();
                ctBCXH_Search = ArrBCXH;
                if (ArrBCXH.Length > 0)
                {
                    tsslchitiet.Enabled = true;
                    tsslPdf.Enabled = true;
                    tsslExcel.Enabled = true;
                    tsslWord.Enabled = true;
                }
                else
                {
                    tsslchitiet.Enabled = false;
                    tsslPdf.Enabled = false;
                    tsslExcel.Enabled = false;
                    tsslWord.Enabled = false;
                }
            }
            catch
            {
            }
        }
        public CascadingDropDownNameValue[] GetJobTitlesByOrganisationalUnit(string knownCategoryValues, string category, string contextKey)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            int organisationalId;
            if (!kv.ContainsKey("OrganizationalUnit") ||
            !Int32.TryParse(kv["OrganizationalUnit"], out organisationalId))
            {

                List<JobTitleView> list = new JobTitleMapper().ListByOrganisationalUnitId(null, "", StatusEnum.Active);
                foreach (JobTitleView ent in list)
                {
                    CascadingDropDownNameValue cdnv;
                    if (ent.Title == contextKey)
                    {
                        cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code, true);
                        values.Add(cdnv);
                    }
                    else
                    {
                        cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code);
                        values.Add(cdnv);
                    }
                }
            }
            else
            {

                List<JobTitleView> list = new JobTitleMapper().ListByOrganisationalUnitId(organisationalId, "", StatusEnum.Active);
                foreach (JobTitleView ent in list)
                {
                    CascadingDropDownNameValue cdnv;
                    if (ent.Title == contextKey)
                    {
                        cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code, true);
                        values.Add(cdnv);
                    }
                    else
                    {
                        cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code);
                        values.Add(cdnv);
                    }
                }
            }
            return values.ToArray();
        }
        public CascadingDropDownNameValue[] GetGradesByJobCode(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            string jobCode;
            if (!kv.ContainsKey("JobTitle"))
            {
                return null;
            }
            jobCode = kv["JobTitle"];

            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<GradeEntity> list = new GradeMapper().ListByJobeCode(jobCode);
            foreach (GradeEntity ent in list)
            {
                string text = ent.Id;
                CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(text, ent.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        //Obtiene el detalle de label y entrega el dataset
        public static DataSet GetReportDataset(IList<Label> labelList, int quantity)
        {
            try
            {

                ReportDetailFormat detail;
                IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();

                string notes = "";

                int seq = 1;
                foreach (Label label in labelList)
                {
                    detail = new ReportDetailFormat();

                    if (label.Product != null)
                    {
                        detail.ProductCode = label.Product.ProductCode;
                        detail.ProductDescription = label.Product.Name;
                    }

                    notes = (label.Notes != null) ? label.Notes : "";

                    if (label.IsLogistic == true)
                    {
                        try { detail.Unit = notes.Split(',')[0].Trim().Replace("Default", ""); }
                        catch { }
                        detail.QtyOrder = label.StartQty; //Aqui guardan las logisitcas las hijas que contienen unas vez se imprimen
                    }
                    else
                    {
                        detail.Unit = label.Unit != null ? label.Unit.Name : "Default";
                        detail.QtyOrder = label.CurrQty;
                    }

                    //detail.BarcodeProduct = label.Product.ProductCode;
                    detail.BarcodeLabel = (label.Barcode != null) ? label.Barcode : "";
                    detail.Lote = (label.LotCode != null) ? label.LotCode : "";
                    detail.Date1 = (label.ExpirationDate != null) ? label.ExpirationDate.Value.ToShortDateString() : "";
                    detail.Printed = DateTime.Today.ToString("MM/dd/yyyy hh:mm:ss");
                    detail.Serial = (label.SerialNumber != null) ? label.SerialNumber : "";
                    detail.Notes = notes;
                    detail.PrintLot = (label.PrintingLot != null) ? label.PrintingLot : "";
                    detail.UserName = (label.CreatedBy != null) ? label.Barcode : "";
                    detail.LogisticNote = ""; // (label.IsLogistic == true) ? "** LOGISTIC **" : "";


                    //Si el Label es de tipo Custom Label, Ejecuta un proceso adicional.
                    //JM 10 de Junio de 2009
                    if (label.LabelType.DocTypeID == LabelType.CustomerLabel)
                    {
                        //For Packages
                        detail.DocNumber = (label.ShippingDocument != null) ? label.ShippingDocument.DocNumber : "";

                        //Sequence
                        try { detail.PrintLot = seq.ToString() + " / " + labelList.Count(); }
                        catch { }

                        //Weight
                        try { detail.Weight = label.DocumentPackages[0].Weight; }
                        catch { }

                        //Dimemsion
                        try { detail.Dimension = label.DocumentPackages[0].Dimension; }
                        catch { }

                        try { detail.Pieces = label.DocumentPackages[0].Pieces; }
                        catch { }



                        //Shipping Address
                        try
                        {
                            DocumentAddress shipAddr = (new DaoFactory()).DaoDocumentAddress().Select(
                                new DocumentAddress { Document = label.ShippingDocument, AddressType = AddressType.Shipping })
                            .Where(f => f.DocumentLine == null).First();

                            detail.ContactPerson = shipAddr.Name; //shipAddr.ContactPerson;

                            //detail.ShipAddress = shipAddr.Name + "\n";
                            detail.ShipAddress = shipAddr.AddressLine1 + " " + shipAddr.AddressLine2 + "\n";
                            detail.ShipAddress += shipAddr.City + ", " + shipAddr.State + " " + shipAddr.ZipCode + ", ";
                            detail.ShipAddress += shipAddr.Country + "\n";
                            detail.ShipAddress += shipAddr.ContactPerson;

                        }
                        catch { }
                    }

                    seq++;
                    detailList.Add(detail);

                }

                //Add Header to DataSet
                XmlSerializer xmlSerializer;
                StringWriter writer = new StringWriter();

                DataSet dd = new DataSet("Details");
                xmlSerializer = new XmlSerializer(detailList.ToArray().GetType());  //  detailList.GetType()
                xmlSerializer.Serialize(writer, detailList.ToArray());
                StringReader reader = new StringReader(writer.ToString());
                dd.ReadXml(reader);
                dd.Tables[0].TableName = "Details";
                return dd;
            }

            catch { return null; }
        }
        public Character[] GetAllCharactersByAccountId(int accountId)
        {
            DbParameter accountIdParameter = _db.CreateParameter(DbNames.GETALLCHARACTERSBYACCOUNTID_ACCOUNTID_PARAMETER, accountId);

            accountIdParameter.DbType = DbType.Int32;

            List<Character> characters = new List<Character>();

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLCHARACTERSBYACCOUNTID_STOREDPROC, CommandType.StoredProcedure, accountIdParameter);

            int ordinalCHARACTER_ID = reader.GetOrdinal(DbNames.CHARACTER_ID);
            int ordinalCHARACTER_ACCOUNTID = reader.GetOrdinal(DbNames.CHARACTER_ACCOUNTID);
            int ordinalCHARACTER_NAME = reader.GetOrdinal(DbNames.CHARACTER_NAME);
            int ordinalCHARACTER_CLASS = reader.GetOrdinal(DbNames.CHARACTER_CLASS);
            int ordinalCHARACTER_LEVEL = reader.GetOrdinal(DbNames.CHARACTER_LEVEL);
            int ordinalCHARACTER_MAPID = reader.GetOrdinal(DbNames.CHARACTER_MAPID);
            int ordinalCHARACTER_CURRENTHP = reader.GetOrdinal(DbNames.CHARACTER_CURRENTHP);
            int ordinalCHARACTER_CURRENTMANA = reader.GetOrdinal(DbNames.CHARACTER_CURRENTMANA);
            int ordinalCHARACTER_STRENGTH = reader.GetOrdinal(DbNames.CHARACTER_STRENGTH);
            int ordinalCHARACTER_STAMINA = reader.GetOrdinal(DbNames.CHARACTER_STAMINA);
            int ordinalCHARACTER_DEXTERITY = reader.GetOrdinal(DbNames.CHARACTER_DEXTERITY);
            int ordinalCHARACTER_ENERGY = reader.GetOrdinal(DbNames.CHARACTER_ENERGY);

            while (reader.Read())
            {
                Character c = new Character
                {
                    CharacterId = reader.GetInt32(ordinalCHARACTER_ID),
                    AccountId = reader.GetInt32(ordinalCHARACTER_ACCOUNTID),
                    Name = reader.GetString(ordinalCHARACTER_NAME),
                    Class = reader.GetByte(ordinalCHARACTER_CLASS),
                    Level = reader.GetInt16(ordinalCHARACTER_LEVEL),
                    MapId = reader.GetInt32(ordinalCHARACTER_MAPID),
                    CurrentHp = reader.GetInt32(ordinalCHARACTER_CURRENTHP),
                    CurrentMana = reader.GetInt32(ordinalCHARACTER_CURRENTMANA),
                    Strength = reader.GetInt16(ordinalCHARACTER_STRENGTH),
                    Stamina = reader.GetInt16(ordinalCHARACTER_STAMINA),
                    Dexterity = reader.GetInt16(ordinalCHARACTER_DEXTERITY),
                    Energy = reader.GetInt16(ordinalCHARACTER_ENERGY)
                };

                characters.Add(c);
            }

            reader.Close();
            _db.Close();

            foreach (Character c in characters)
            {
                //c.Equipments = GetAllItemsInBag(0, c.CharacterId).Cast<Equipment>().ToList();

                var equips = itemDataManager.GetAllItemsInBag(0, c.CharacterId).Cast<Equipment>().ToList();

                var neck = equips.Where(x => x is Necklace);
                var ring = equips.Where(x => x is Ring);
                var head = equips.Where(x => x is Head);
                var body = equips.Where(x => x is Body);
                var feet = equips.Where(x => x is Feet);
                var hand = equips.Where(x => x is Hand);
                var cape = equips.Where(x => x is Cape);
                var charm = equips.Where(x => x.Slot == (byte)Slot.CrystalMirror);
                var mirror = equips.Where(x => x.Slot == (byte)Slot.Mirror);

                c.Necklace = neck.Count() == 0 ? null : neck.First() as Necklace;
                c.Ring = ring.Count() == 0 ? null : ring.First() as Ring;
                c.Head = head.Count() == 0 ? null : head.First() as Head;
                c.Body = body.Count() == 0 ? null : body.First() as Body;
                c.Feet = feet.Count() == 0 ? null : feet.First() as Feet;
                c.Hand = hand.Count() == 0 ? null : hand.First() as Hand;
                c.Cape = cape.Count() == 0 ? null : cape.First() as Cape;
                c.Charm = charm.Count() == 0 ? null : charm.First() as Equipment;
                c.Mirror = mirror.Count() == 0 ? null : mirror.First() as Mirror;

            }

            return characters.ToArray();
        }
        public CascadingDropDownNameValue[] GetNationalities(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<NationalityEntity> list = new NationalityMapper().List("");
            foreach (NationalityEntity ent in list)
            {
                CascadingDropDownNameValue cdnv;

                if (ent.Title == contextKey)
                {
                    cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString(), true);
                }
                else
                {
                    cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString());
                }
                values.Add(cdnv);
            }

            return values.ToArray();
        }
        private void SelectData()
        {
            List<Entities.HangHoa> listTemp = new List<Entities.HangHoa>();
            int stt = 0;
            MANG = LayHangHoa();
            MANG = OrderBy(MANG);

            foreach (Entities.HangHoa item in MANG)
            {
                stt++;
                item.Stt = stt;
                listTemp.Add(item);
            }

            dgvQuanLyHangHoa.DataSource = listTemp.ToArray();
            fix();
        }
        public CascadingDropDownNameValue[] GetWorkTypes(string knownCategoryValues, string category, string contextKey)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            string[] workTypesNames = Enum.GetNames(typeof(WorkType));
            Array workTypesValues = Enum.GetValues(typeof(WorkType));

            CascadingDropDownNameValue cdnv;

            for (int i = 1; i <= workTypesNames.Length - 1; i++)
            {
                if (workTypesNames[i] == contextKey)
                {
                    cdnv = new CascadingDropDownNameValue(workTypesNames[i], i.ToString(), true);
                }
                else
                {
                    cdnv = new CascadingDropDownNameValue(workTypesNames[i], i.ToString());
                }

                values.Add(cdnv);
            }

            return values.ToArray();
        }
        public void GiaVonBanHang(ChiTietHDBanHang[] ct)
        {
            try
            {
                List<GiaVonBanHang> gvbhArr = new List<GiaVonBanHang>();
                GoiHang[] goiHang = _goihang;
                GiaVon[] gv = GiaVon();
                bool isHangHoa = false;

                foreach (ChiTietHDBanHang bh in ct)
                {
                    GiaVonBanHang gvbh = new GiaVonBanHang();
                    ChiTietHDBanHang bh1 = bh;
                    foreach (GiaVon item in gv.Where(item => item.MaHangHoa.Equals(bh1.MaHangHoa)))
                    {
                        gvbh.HanhDong = "Insert";
                        gvbh.MaHangHoa = bh.MaHangHoa;
                        gvbh.MaHoaDon = bh.MaHDBanHang;
                        gvbh.GiaVon = item.Gia;
                        gvbhArr.Add(gvbh);
                        isHangHoa = true;
                        break;
                    }
                    // neu ko phai la hang hoa thi la gia von trong goi hang
                    if (isHangHoa) continue;
                    gvbh = GetGvGoiHang(bh.MaHDBanHang, bh.MaHangHoa, goiHang);

                    if (gvbh != null)
                        gvbhArr.Add(gvbh);
                }

                cl = new Server_Client.Client();
                Client1 = cl.Connect(Luu.IP, Luu.Ports);
                foreach (GiaVonBanHang item in gvbhArr.ToArray())
                {
                    Clientstrem = cl.SerializeObj(Client1, "GiaVonBanHang", item);
                }
                // đổ mảng đối tượng vào datagripview
                bool kt = false;
                kt = (bool)cl.DeserializeHepper(Clientstrem, kt);
            }
            catch (Exception)
            {

            }
        }
        public CascadingDropDownNameValue[] GetContractsTemplates(string knownCategoryValues, string category)
        {
            List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

            List<ContractTemplateEntity> list = new ContractTemplateMapper().ListWithAdvancedFilter("", StatusEnum.Active);
            foreach (ContractTemplateEntity ent in list)
            {
                CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString());
                values.Add(cdnv);
            }

            return values.ToArray();
        }