private void btnTaoTK_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }

            if (tbPass1.Text != tbPass2.Text)
            {
                MessageBox.Show("Mật khẩu không khớp.");
                return;
            }
            if (tbPass1.Text == string.Empty || tbPass2.Text == string.Empty)
            {
                MessageBox.Show("Mật khẩu không được để trống.");
                return;
            }

            string insertString = @" insert into NewUserAccount(UserID, UserAccount, Password) values (@UserID, @UserAccount, @password) ";

            // xem các chức năng để tạo mặc định
            List <XL2.cChucNang> listChucNang = XL2.TaoChucNang();
            string templateString             = " insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, {0}, 0) ";
            string chuoi = string.Empty;

            for (int i = 0; i < listChucNang.Count; i++)
            {
                chuoi         = string.Format(templateString, listChucNang[i].ID);
                insertString += chuoi;
            }
            int tempUserID = (int)cbTaikhoanWE.SelectedValue;

            string tempUserAccount = tbTenTaiKhoan.Text;
            string tempPass        = tbPass1.Text;
            string tempPassEncrypt = MyUtility.Mahoa(tempPass);

            try {
                #region

                /* insertString = @" insert into NewUserAccount(UserID, UserAccount, Password) values (@UserID, @UserAccount, @password)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 10001, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 10002, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 20001, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 20002, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 20003, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 30001, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 30002, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 40001, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 40002, 0)
                 *                                      insert into MenuPrivilege (UserID, MenuID, IsYes) values (@UserID, 60001, 0) "
                 */

                #endregion

                int kq = SqlDataAccessHelper.ExecNoneQueryString(insertString
                                                                 , new[] { "@UserID", "@UserAccount", "@password" }
                                                                 , new object[] { tempUserID, tempUserAccount, tempPassEncrypt }, CanLog: false);
                if (kq != 0)
                {
                    ACMessageBox.Show("Thêm tài khoản thành công.", "Thông báo", 2000);
                }
                else
                {
                    MessageBox.Show("Không thêm được tài khoản.", "Lỗi", MessageBoxButtons.OK);
                }
                Load_dataGridNewUserAccount();
                Load_cbTaikhoanWE();
            } catch (Exception exception) {
                lg.Error(string.Format("[{0}]_[{1}]\n", this.Name, System.Reflection.MethodBase.GetCurrentMethod().Name), exception);
                MessageBox.Show("Mất kết nối đến máy chủ. Vui lòng thử lại.", "Lỗi", MessageBoxButtons.OK);
            }
        }
        private void KetLuong(object sender, WaitWindowEventArgs e)
        {
            #region lấy thông tin từ csdl và khỏi tạo  nv

            var ngaydauthang              = MyUtility.FirstDayOfMonth(m_Thang);
            var ngaycuoithang             = MyUtility.LastDayOfMonth(m_Thang);
            var tableDSNVChiCongnhatThang = DAO.LayTableCongNhat(ngaydauthang);
            var tableDSThuchiThang        = DAO.LayDSThuchiThang(ngaydauthang);
            var tableKetcongNgay          = DAO.LayKetcongNgay(ngaydauthang, ngaycuoithang);
            var tableKetcongCa            = DAO.LayKetcongCa(ngaydauthang, ngaycuoithang);
            var tableXPVang = DAO.LayTableXPVang(ngaydauthang, ngaycuoithang);
            var tableNgayLe = DAO.DocNgayLe(ngaydauthang, ngaycuoithang);

            var dsnv       = new List <cUserInfo>();
            var dsphongban = new List <cPhongBan>();
            XL.KhoiTaoDSPhongBan(dsphongban);             // khởi tạo các phòng ban để cập nhật thông tin phòng ban cho nhân viên tính công
            XL.KhoiTaoDSNV_TinhLuong(dsnv, dsphongban);   // khởi tạo tất cả nhân viên tính công, bao gồm cả công nhật ngày(nv chính thức) và công nhật tháng

            #endregion

            #region             //load cong phu cap tung ngay cho tat ca nv, ke ca cong nhat, rieng truong hop cong nhat se xu ly ngay ben duoi

            foreach (var nv in dsnv)
            {
                nv.DSNgayCong = new List <cNgayCong>();
                nv.DSVang     = new List <cLoaiVang>();
                for (DateTime indexNgay = ngaydauthang; indexNgay <= ngaycuoithang; indexNgay = indexNgay.AddDays(1d))
                {
                    XL.LoadNgayCong(nv.MaCC, nv.DSNgayCong, indexNgay, tableKetcongNgay, tableKetcongCa);
                }
                XL.LoadDSXPVang_Le(nv.MaCC, tableXPVang, tableNgayLe, nv.DSVang);                //info trường hợp nhân viên công nhật sẽ được xử lý bên dưới
                XL.PhanPhoi_DSVang7(nv.DSVang, nv.DSNgayCong);

                XL.LoadThongtinLamViecCongNhat(nv.MaCC, ref nv.NgayBDCongnhat, ref nv.NgayKTCongnhat, ref nv.LoaiCN, nv.DSNgayCong, tableDSNVChiCongnhatThang);
            }


            #endregion

            //có được ds nhân viên với công, phụ cấp, các loại vắng, công ngày lễ --> bắt đầu tính lương
            #region lấy thông số để tính lương
            var sanluong01           = (int)(numSanLuong.Value);
            var dongia02             = (int)numDonGia.Value;
            var perTrichQuyLuong     = (int)numTrichQuyLuong.Value;
            var sanluongGiacongNoiBo = (int)numSanluongGiacongNoibo.Value;
            var dongiaGiacongNoiBo   = (int)numDongiaGiacongNoibo.Value;
            var sanluongGiacongNgoai = (int)numSanluongGiacongNgoai.Value;
            var dongiaGiacongNgoai   = (int)numDongiaGiacongNgoai.Value;
            var mucLuongToithieu     = (int)numLuongTT.Value;
            var DinhMuccomtrua       = (int)numDinhMucComTrua.Value;

            double tongQuy100Per03 = Convert.ToDouble(sanluong01) * Convert.ToDouble(dongia02);
            double _80perQuy100_04 = tongQuy100Per03 * (perTrichQuyLuong / 100d);             // ko cần round vì 220*0.8=176 chẵn

            #endregion
            // xác định công chuẩn của tháng
            var congChuanThang = XL.TinhCongChuanCuaThang(ngaydauthang);
            int temp           = 0;
            #region             // thống kê công, phụ cấp hàng ngày của từng nhân viên chính thức//trường hợp nhân viên vừa công nhật vừa chính thức thì chỉ thống kê ngày công sau ngày kết thúc công nhật
            foreach (var nv in dsnv)
            {
                // thống kê công và phụ cấp từng nv
                XL.ThongKeThang(ref nv.ThongKeThang, nv.DSNgayCong, nv.NgayBDCongnhat, nv.NgayKTCongnhat, nv.LoaiCN, out temp, out temp);
                // tính công chờ việc: 1.nv công nhật ko cv. 2. nv mới chính thức thì chỉ giữ công cv khai báo
                if (nv.LoaiCN == LoaiCongNhat.NVCongNhat)                // nhân viên làm công nhật, công cv tự động, khai báo = 0
                {
                    nv.ThongKeThang.CongCV_Auto = 0f;
                    nv.ThongKeThang.CongCV_KB   = 0f;
                }
                else
                {
                    if (nv.LoaiCN == LoaiCongNhat.NVChinhThuc)                    // nhân viên chính thức
                    {
                        nv.ThongKeThang.CongCV_Auto = congChuanThang -
                                                      /*(nv.ThongKeThang.Cong + nv.ThongKeThang.Le + nv.ThongKeThang.Phep + //ver4.0.0.0*/
                                                                                                                                                                 /*(nv.ThongKeThang.TongNgayLV + nv.ThongKeThang.Le + nv.ThongKeThang.Phep + //ver4.0.0.1*/
                                                      (nv.ThongKeThang.TongNgayLV4008
                                                       + nv.ThongKeThang.TongTruCongTreVR + nv.ThongKeThang.TongTruCongSomVR + nv.ThongKeThang.TreSom_KoDuBuCong //ver 4.0.0.8
                                                       + nv.ThongKeThang.Phep + nv.ThongKeThang.Le                                                               //ver4.0.0.8
                                                       + nv.ThongKeThang.BHXH + nv.ThongKeThang.H_CT_PT
                                                       + nv.ThongKeThang.PTDT + nv.ThongKeThang.NghiRo + nv.ThongKeThang.CongCV_KB);                             //DANGLAM
                        if (nv.ThongKeThang.CongCV_Auto < 0f)
                        {
                            nv.ThongKeThang.CongCV_Auto = 0f;
                        }
                    }
                    else                    // nhân viên chính thức vừa công nhật thì công cv_auto =0, công cv khai báo ko đổi
                    {
                        nv.ThongKeThang.CongCV_Auto = 0f;
                    }
                }
                nv.ThongKeThang.CongCV = nv.ThongKeThang.CongCV_Auto + nv.ThongKeThang.CongCV_KB;
            }

            #endregion

            #region             // tính lương công nhật cho các nhân viên làm công nhật và tổng lương công nhật

            double TongLuongCongNhat_AllNV = 0d;

            foreach (DataRow row in tableDSNVChiCongnhatThang.Rows.Cast <DataRow>())
            {
                // lấy thông tin
                var macc        = (int)row["UserEnrollNumber"];
                var dongiaLuong = (int)row["DonGiaLuong"];
                var soNgayCong  = (float)row["SoNgayCong"];
                var TamUng      = (double)row["TamUng"];
                // xác định nhân viên
                var nv = dsnv.Find(o => o.MaCC == macc);
                if (nv == null)
                {
                    continue;
                }
                nv.ThongKeThang.Cong_Congnhat = soNgayCong;
                nv.chiTietLuong.CongNhat      = soNgayCong * dongiaLuong;            //ko trừ tạm ứng, tạm ứng chỉ ở phần thực lãnh mới ghi
                TongLuongCongNhat_AllNV      += nv.chiTietLuong.CongNhat;
            }

            #endregion

            #region             //đọc danh sách thu chi cho từng nhân viên (lưu ý ko đọc phụ cấp của nhân viên công nhật

            foreach (DataRow row in tableDSThuchiThang.Rows.Cast <DataRow>())
            {
                var macc = (int)row["UserEnrollNumber"];
                // xác định nhân viên
                var nv = dsnv.Find(o => o.MaCC == macc);
                if (nv == null)
                {
                    continue;
                }
                nv.chiTietLuong.KhauTru.TamUng     = (double)row["TamUng"];
                nv.chiTietLuong.LuongDieuChinh     = (double)row["LuongDieuChinh"];
                nv.chiTietLuong.MucDongBHXH        = (float)row["MucDongBHXH"];
                nv.chiTietLuong.KhauTru.ThuChiKhac = (double)row["ThuChiKhac"];
            }

            #endregion

            #region             // tính lương cho nv chính thức

            double tong_qlcb_2 = 0d, tong_SPLamRa_B2_2 = 0d, tongQuyLuongCV = 0d, tongQuyLuongNghiDinhCP = 0d, tongChiKhacTuQuyLuong = 0d, tongQuyLuongSP = 0d;
            foreach (var nv in dsnv.Where(o => o.LoaiCN != LoaiCongNhat.NVCongNhat))
            {
                //if (Math.Abs(nv.ThongKeThang.Cong - 0f) < 0.01f) nv.ThongKeThang.CongCV = 0f; //fortesting nếu ko chấm công thì cũng ko có công cv
                XL.TinhLuongCoBan_CongVaPC_A202(nv.HeSo.LuongCB, mucLuongToithieu, nv.ThongKeThang.Cong, nv.ThongKeThang.PhuCaps._TongPC,
                                                nv.ThongKeThang.Phep, nv.ThongKeThang.H_CT_PT, nv.ThongKeThang.PTDT, nv.ThongKeThang.Le, nv.ThongKeThang.CongCV,                                                //DANGLAM
                                                out nv.chiTietLuong.LCB_Theo.CongThucTe, out nv.chiTietLuong.LCB_Theo.CheDoNghi, out nv.chiTietLuong.LCB_Theo.CongCV,
                                                out nv.chiTietLuong.LCB_Theo.PhuCap);
                tongQuyLuongCV += nv.chiTietLuong.LCB_Theo.CongCV;
                //tongQuyLuongNghiDinhCP += nv.chiTietLuong.LCB_Theo.TongCong_CD_CV_PC; // yêu cầu cũ (T1/2015) là có lương chờ việc
                tongQuyLuongNghiDinhCP += nv.chiTietLuong.LCB_Theo.Cong_CD_PC;                // yêu cầu mới (T8/2015) là tách lương chờ việc ra

                //ver4.0.0.7 tong_qlcb_2 += nv.chiTietLuong.LCB_Theo.TongCong_CD_CV_PC + nv.chiTietLuong.LuongDieuChinh; //yêu cầu mới (T8/2015) là tách lương chờ việc ra khỏi quỹ lương cơ bản đưa vào quỹ lương sản phẩm
                tong_qlcb_2           += nv.chiTietLuong.LCB_Theo.Cong_CD_PC + nv.chiTietLuong.LuongDieuChinh;       //info tong_qlcb_2 bao gồm lương cb 1nv, bồi dưỡng ca 3 1nv, lương tháng trước 1 nv
                tongChiKhacTuQuyLuong += nv.chiTietLuong.KhauTru.ThuChiKhac;

                XL.TinhSPLamRa_CongVaPC_B102(nv.HeSo.LuongCV, nv.ThongKeThang.Cong, nv.ThongKeThang.PhuCaps._TongPC, nv.ThongKeThang.Phep, nv.ThongKeThang.H_CT_PT, nv.ThongKeThang.PTDT, nv.ThongKeThang.Le,                //DANGLAM
                                             out nv.chiTietLuong.SPLamRa_Theo.CongThucTe, out nv.chiTietLuong.SPLamRa_Theo.CheDoNghi, out nv.chiTietLuong.SPLamRa_Theo.PhuCap);
                tong_SPLamRa_B2_2 += nv.chiTietLuong.SPLamRa_Theo.TongSPLamRa;
                // tính khấu trừ BHXH
                nv.chiTietLuong.KhauTru.BHXH = Convert.ToDouble(nv.HeSo.BHXH_YT_TN * mucLuongToithieu * (nv.chiTietLuong.MucDongBHXH / 100f));
                // tính tiền cơm trưa
                var temp1 = DinhMuccomtrua - ((DinhMuccomtrua / congChuanThang) * nv.ThongKeThang.SoNgayNghiRO_NguyenNgay);
                nv.chiTietLuong.TienComTrua = (temp1 >= 0d) ? temp1 : 0d;
            }
            var    chitienGiacongNoibo       = Convert.ToDouble(sanluongGiacongNoiBo) * Convert.ToDouble(dongiaGiacongNoiBo);
            var    chitienGiacongNgoai       = Convert.ToDouble(sanluongGiacongNgoai) * Convert.ToDouble(dongiaGiacongNgoai);
            var    tong_qlSP_A71_1_VaGiaCong = (_80perQuy100_04 + chitienGiacongNoibo + chitienGiacongNgoai) - tong_qlcb_2 - TongLuongCongNhat_AllNV; // yêu cầu mới (T8/2015) là tách lương chờ việc ra
            double giaTri_1SP_B3_1           = (Math.Abs(tong_SPLamRa_B2_2 - 0d) > 0.001d) ? (tong_qlSP_A71_1_VaGiaCong / tong_SPLamRa_B2_2) : 0d;    // tính ra được 1 đơn vị sản phẩm có giá bao nhiêu
            //double tong0 = 0d, tong1 = 0d, tong2 = 0d, tong3 = 0d, tong4 = 0d, tong5 = 0d, tong6 = 0d, tong7 = 0d, tong8 = 0d, tong9 = 0d, tong10 = 0d, tong11 = 0d, tong12 = 0d, tong13 = 0d, tong14 = 0d, tong15 = 0d, tong16 = 0d, tong17 = 0d, tong18 = 0d, tong19 = 0d, tong20 = 0d, tong21 = 0d, tong22 = 0d, tong23 = 0d, tong24 = 0d, tong25 = 0d, tong26 = 0d, tong27 = 0d, tong28 = 0d, tong29 = 0d, tong30 = 0d, tong31 = 0d, tong32 = 0d, tong33 = 0d, tong34 = 0d, tong35 = 0d, tong36 = 0d;

            foreach (var nv in dsnv.Where(o => o.LoaiCN != LoaiCongNhat.NVCongNhat))
            {
                nv.chiTietLuong.LSP_Theo.CongThucTe = nv.chiTietLuong.SPLamRa_Theo.CongThucTe * giaTri_1SP_B3_1;
                nv.chiTietLuong.LSP_Theo.CheDoNghi  = nv.chiTietLuong.SPLamRa_Theo.CheDoNghi * giaTri_1SP_B3_1;
                nv.chiTietLuong.LSP_Theo.PhuCap     = nv.chiTietLuong.SPLamRa_Theo.PhuCap * giaTri_1SP_B3_1;
                tongQuyLuongSP += nv.chiTietLuong.LSP_Theo.TongCong_CD_PC;
                //fortesting region [03]
            }

            #endregion

            //fortesting testing region [01]
            #region             // cập nhật lương xuống csdl , trước khi cập nhật thì xoá lương cũ

            // cập nhật lương xuống csdl , trước khi cập nhật thì xoá lương cũ
            int kq1 = SqlDataAccessHelper.ExecNoneQueryString(
                "delete from KetLuongThang where Thang = @Thang", new string[] { "@Thang" }, new object[] { m_Thang });                 //INFO LOG DO KẾT LƯƠNG THÁNG THỰC HIỆN

            foreach (var nv in dsnv.Where(o => o.LoaiCN != LoaiCongNhat.NVCongNhat))
            {
                int kq = DAO.InsKetLuongThang(m_Thang, nv);
                //if (kq == 0) MessageBox.Show("Xảy ra lỗi tại vị trí NV: " + nv.MaCC + nv.TenNV);//fortesting
            }

            // sau khi cập nhật lương từng nhân viên thì cập nhật thông số kết lương tháng
            int kq2 = DAO.UpdInsThongsoKetluongThang(m_Thang,
                                                     XL2.PC30, XL2.PC50, XL2.PCTCC3, XL2.PC100, XL2.PC160, XL2.PC200, XL2.PC290,
                                                     sanluong01, dongia02, perTrichQuyLuong,
                                                     sanluongGiacongNoiBo, dongiaGiacongNoiBo, sanluongGiacongNgoai, dongiaGiacongNgoai,
                                                     mucLuongToithieu, /*donGiaBdCa3,*/ DinhMuccomtrua,
                                                     tongQuyLuongCV, tongQuyLuongNghiDinhCP,
                                                     tongChiKhacTuQuyLuong, tongQuyLuongSP, giaTri_1SP_B3_1);

            //ghi log
            string noidung = string.Format("Kết lương tháng [{0}]", m_Thang.ToString("MM/yyyy"));
            DAO.GhiNhatKyThaotac("Kết lương", noidung);

            #endregion
        }
示例#3
0
 public void Run()
 {
     Main05();
     MyUtility.Pause("Od jutra zabieram się do pracy ... \n");
 }
示例#4
0
 public void Run()
 {
     Main02();
     MyUtility.MyPause("Repetitio mater studiorum est ...");
 }
        private void XuatBBLuong(object sender, WaitWindowEventArgs e)
        {
            string tenNVLapBieu  = (string)e.Arguments[0];
            string saveFileName  = (string)e.Arguments[1];
            var    ngaydauthang  = MyUtility.FirstDayOfMonth(m_Thang);
            var    ngaycuoithang = MyUtility.LastDayOfMonth(m_Thang);
            //#region lấy dữ liệu kết lương để xuất

            var tableKetLuongThang        = DAO.LayKetLuongThang(ngaydauthang);
            var tableThongsoKetluongThang = DAO.LayThongsoKetluongThang(ngaydauthang);
            var tableDSNVChiCongnhatThang = DAO.LayTableCongNhat(ngaydauthang);
            var tableTongLuongCongnhat    = SqlDataAccessHelper.ExecuteQueryString(
                @"select  CAST(SUM (SoNgayCong*DonGiaLuong) as float)  from DSNVChiCongNhatThang where Thang=@Thang",
                new string[] { "@Thang" }, new object[] { ngaydauthang });
            var tongLuongCongnhat  = (tableTongLuongCongnhat.Rows[0][0] != DBNull.Value) ? (double)tableTongLuongCongnhat.Rows[0][0] : 0d;
            var tongLuongDieuchinh = (from DataRow row in tableKetLuongThang.Rows
                                      let luongdieuchinh = (row["LuongDieuChinh"] != DBNull.Value)
                                                                                                                           ? (double)row["LuongDieuChinh"]
                                                                                                                           : 0d
                                                           select luongdieuchinh).Sum();
            var tableKetcongNgay = DAO.LayKetcongNgay(ngaydauthang, ngaycuoithang);
            var tableKetcongCa   = DAO.LayKetcongCa(ngaydauthang, ngaycuoithang);
            var tableXPVang      = DAO.LayTableXPVang(ngaydauthang, ngaycuoithang);
            var tableNgayLe      = DAO.DocNgayLe(ngaydauthang, ngaycuoithang);
            var dsnv             = new List <cUserInfo>();

            ChuanBiDuLieuXuatLuong(dsnv, ngaydauthang, ngaycuoithang, tableKetLuongThang, tableKetcongNgay, tableKetcongCa, tableXPVang, tableNgayLe, tableDSNVChiCongnhatThang);

            //#endregion

            //fortesting testing region [02]
            using (var p = new ExcelPackage()) {
                //1. xuat bb bang thong so san luong, don gia, he so pc
                #region lay thong so cac loai pc de ghi cot tieu de
                int pc30   = (int)tableThongsoKetluongThang.Rows[0]["HSPCDem"];
                int pc50   = (int)tableThongsoKetluongThang.Rows[0]["HSPCTangCuong"];
                int pctcc3 = (int)tableThongsoKetluongThang.Rows[0]["HSPCTangCuong_Dem"];
                int pc100  = (int)tableThongsoKetluongThang.Rows[0]["HSPC200"];
                int pc160  = (int)tableThongsoKetluongThang.Rows[0]["HSPC260"];
                int pc200  = (int)tableThongsoKetluongThang.Rows[0]["HSPC300"];
                int pc290  = (int)tableThongsoKetluongThang.Rows[0]["HSPC390"];
                #endregion
                //2. xuat bb bang ket cong thang
                #region ghi sheet bang ket cong thang trinh ky

                p.Workbook.Worksheets.Add("BangKetCong");
                var ws = p.Workbook.Worksheets["BangKetCong"];
                ws.Name = "BangKetCong";                 //Setting Sheet's name
                XL.ExportSheetBangKetcongThang(ws, ngaydauthang, ngaycuoithang, dsnv, string.Empty, string.Empty, pc30, pc50, pctcc3, pc100, pc160, pc200, pc290);

                #endregion
                //3. xuat bb chi tiết kết công
                #region ghi sheet chi tiết kết công

                p.Workbook.Worksheets.Add("ChiTietKetCong");
                ws      = p.Workbook.Worksheets["ChiTietKetCong"];
                ws.Name = "ChiTietKetCong";                 //Setting Sheet's name
                XL.ExportSheetBangChiTietKetCong(ws, ngaydauthang, ngaycuoithang, dsnv, pc30, pc50, pctcc3, pc100, pc160, pc200, pc290);

                #endregion
                //4. xuat bb bang luong cong nhat
                #region ghi sheet bang luong cong nhat

                p.Workbook.Worksheets.Add("BangLuongCongNhat");
                ws      = p.Workbook.Worksheets["BangLuongCongNhat"];
                ws.Name = "BangLuongCongNhat";
                XL.ExportSheetBangLuongCongNhat(ws, ngaydauthang, tableDSNVChiCongnhatThang);

                #endregion
                //5. xuat bb bang luong chinh thuc
                #region ghi sheet bảng lương

                p.Workbook.Worksheets.Add("BangLuong");
                ws      = p.Workbook.Worksheets["BangLuong"];
                ws.Name = "BangLuong";
                XL.ExportSheetBangLuong(ws, m_Thang, dsnv, tenNVLapBieu);

                #endregion
                //6. xuat bb bang tong hop so lieu giam doc ky duyet
                #region ghi sheet bảng tổng hợp số liệu

                p.Workbook.Worksheets.Add("BangTongHopChi");
                ws      = p.Workbook.Worksheets["BangTongHopChi"];
                ws.Name = "BangTongHopChi";
                XL.ExportSheetTongHopChi(ws, m_Thang, tableThongsoKetluongThang, tongLuongCongnhat, tongLuongDieuchinh);

                #endregion
                //7. xuat sheet thong ke sữa
                #region ghi sheet thống kê BD ĐH

                p.Workbook.Worksheets.Add("BangThongKeBoiDuongDocHai");
                ws      = p.Workbook.Worksheets["BangThongKeBoiDuongDocHai"];
                ws.Name = "BangThongKeBoiDuongDocHai";
                XL.ExportSheetBangThongKeSua(ws, ngaydauthang, ngaycuoithang, dsnv);

                #endregion


                Byte[] bytes = p.GetAsByteArray();
                XL.XuatFileExcel(saveFileName, bytes, "frm4LuuHSPC XuatBBLuong");
            }
        }
    public List <DataUser> GetUser(int page, int pageSize, TypeSearchModel modelSearch)
    {
        int skip = (page - 1) * pageSize;
        int take = pageSize;

        DBEntities db   = new DBEntities();
        var        data = db.Users
                          .OrderBy(x => x.Position)
                          .Select(x => new DataUser
        {
            Avatar         = x.Avatar != null ? x.Avatar : string.Empty,
            FullName       = x.FullName != null ? x.FullName : string.Empty,
            UserID         = x.UserID != null ? x.UserID : string.Empty,
            NameSchool     = x.NameSchool != null ? x.NameSchool : string.Empty,
            JobStatus      = x.StatusJob == null ? false : x.StatusJob.Value,
            CreateTime     = x.CreateTime.Value,
            Tag            = x.TagSkill != null ? x.TagSkill : string.Empty,
            IDCompany      = x.CompanyID == null ? 0 : x.CompanyID.Value,
            TitleCompany   = x.Company.Title != null ? x.Company.Title : string.Empty,
            GraduationYear = x.GraduationYear == null ? 0: x.GraduationYear.Value,
            Skill          = string.Empty,
            FlagPage       = false
        });

        string keySearch = modelSearch.KeySearch.ToSafetyString();

        if (modelSearch.Type == "muti")
        {
            foreach (var item in modelSearch.KeySearch.SplitToTextValueArray(";", ":", StringSplitOptions.RemoveEmptyEntries))
            {
                if (item.Text == "sk")
                {
                    data = data.Where(x => x.Tag != null && x.Tag.Contains(item.Value));
                }

                if (item.Text == "sc")
                {
                    data = data.Where(x => x.NameSchool.Contains(item.Value));
                }
            }
        }

        if (modelSearch.Type == "sk")
        {
            data = data.Where(x => x.Tag != null && x.Tag.Contains(keySearch));
        }
        if (modelSearch.Type == "sc")
        {
            data = data.Where(x => x.NameSchool.Contains(keySearch));
        }
        if (modelSearch.Type == "cp")
        {
            int idCompany = keySearch.ToInt();
            data = data.Where(x => x.IDCompany == idCompany);
        }
        if (modelSearch.Type == "job")
        {
            if (modelSearch.KeySearch == "1")
            {
                data = data.Where(x => x.JobStatus == true);
            }
            if (modelSearch.KeySearch == "2")
            {
                data = data.Where(x => x.JobStatus == false);
            }
        }
        if (modelSearch.Type == "keyname")
        {
            data = data.Where(x => x.FullName.Contains(modelSearch.KeySearch));
        }

        List <DataUser> listUser = new List <DataUser>();

        int coutData = data.Count();
        int demFist  = 0;

        foreach (var item in data)
        {
            demFist++;

            item.Skill = MyUtility.LoadSkill(item.UserID);
            if (demFist == coutData)
            {
                item.FlagPage = true;
            }
            listUser.Add(item);
        }


        return(listUser.Skip(skip).Take(take).ToList());
    }
示例#7
0
 public void Run()
 {
     Main05();
     MyUtility.Pause("Życie jest ciężkie, a potem się umiera ...");
 }
示例#8
0
        public override async Task <List <StreamClass> > DownloadLiveAsync()
        {
            var result = new List <StreamClass>();

            try
            {
                XDocument  xDocument = XDocument.Parse(MyUtility.RemoveSpecialChars(await new MyHttpClient().GetStringAsync(url_, null)));
                XNamespace ns        = "http://www.w3.org/2005/Atom";
                XNamespace ct        = "http://gae.cavelis.net";
                result = (from entry in xDocument.Root.Elements(ns + "entry")
                          let owner = entry.Element(ns + "author").Element(ns + "name").Value
                                      let title = entry.Element(ns + "title").Value
                                                  let description = entry.Element(ns + "summary").Value
                                                                    let start_time = MyUtility.FormatDate(entry.Element(ct + "start_date").Value, dateFormat_, isUniversal_, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal)
                                                                                     let url = entry.Element(ns + "id").Value
                                                                                               let listener = MyUtility.TryParseOrDefault <string, int>(int.TryParse, entry.Element(ct + "listener").Value)
                                                                                                              select new StreamClass(title, url, owner, listener, start_time)).ToList();
            }
            catch (HttpClientException innerException)
            {
                throw innerException;
            }
            catch (Exception innerException2)
            {
                throw innerException2;
            }

            return(result);
        }
示例#9
0
    public static void LoadIngredients(string recipePath)
    {
        Debug.Log("*****");
        Debug.Log("Loading scene: " + recipePath);

        var cellPackSceneJsonPath = recipePath;//Application.dataPath + "/../Data/HIV/cellPACK/BloodHIV1.0_mixed_fixed_nc1.json";

        if (!File.Exists(cellPackSceneJsonPath))
        {
            throw new Exception("No file found at: " + cellPackSceneJsonPath);
        }

        var resultData = MyUtility.ParseJson(cellPackSceneJsonPath);

        //we can traverse the json dictionary and gather ingredient source (PDB,center), sphereTree, instance.geometry if we want.
        //the recipe is optional as it will gave more information than just the result file.

        //idea: use secondary color scheme for compartments, and analogous color for ingredient from the recipe baseColor
        current_color = 0;
        //first grab the total number of object
        int nIngredients = 0;

        if (resultData["cytoplasme"] != null)
        {
            nIngredients += resultData["cytoplasme"]["ingredients"].Count;
        }

        for (int i = 0; i < resultData["compartments"].Count; i++)
        {
            nIngredients += resultData["compartments"][i]["interior"]["ingredients"].Count;
            nIngredients += resultData["compartments"][i]["surface"]["ingredients"].Count;
        }
        //generate the palette
        //ColorsPalette   = ColorGenerator.Generate(nIngredients).Skip(2).ToList();
        ColorsPalette = ColorGenerator.Generate(8).Skip(2).ToList();//.Skip(2).ToList();
        List <Vector3> startKmeans = new List <Vector3>(ColorsPalette);

        //paletteGenerator.initKmeans (startKmeans);

        usedColors     = new Dictionary <int, List <int> >();
        ColorsPalette2 = ColorPaletteGenerator.generate(
            6,     // Colors
            ColorPaletteGenerator.testfunction,
            false, // Using Force Vector instead of k-Means
            50     // Steps (quality)
            );
        // Sort colors by differenciation first
        //ColorsPalette2 = paletteGenerator.diffSort(ColorsPalette2);
        //check if cytoplasme present

        Color baseColor = new Color(1.0f, 107.0f / 255.0f, 66.0f / 255.0f);

        if (resultData["cytoplasme"] != null)
        {
            usedColors.Add(current_color, new List <int>());
            baseColor = new Color(1.0f, 107.0f / 255.0f, 66.0f / 255.0f);
            AddRecipeIngredients(resultData["cytoplasme"]["ingredients"], baseColor, "root", "cytoplasme");
            current_color += 1;
        }

        for (int i = 0; i < resultData["compartments"].Count; i++)
        {
            var compartmentName = resultData["compartments"].GetKey(i);

            baseColor = new Color(148.0f / 255.0f, 66.0f / 255.0f, 255.0f / 255.0f);
            usedColors.Add(current_color, new List <int>());

            AddRecipeIngredients(resultData["compartments"][i]["interior"]["ingredients"], baseColor, "root", compartmentName, "interior");

            current_color += 1;
            baseColor      = new Color(173.0f / 255.0f, 255.0f / 255.0f, 66.0f / 255.0f);
            usedColors.Add(current_color, new List <int>());

            AddRecipeIngredients(resultData["compartments"][i]["surface"]["ingredients"], baseColor, "root", compartmentName, "surface");
            current_color += 1;
        }
    }
示例#10
0
        public override async Task <List <StreamClass> > DownloadLiveAsync()
        {
            var result = new List <StreamClass>();

            for (int i = 0; i < RATE_LIMIT; i++)
            {
                //参考URL
                //https://stackoverflow.com/questions/45622188/get-value-from-twitch-api
                //日本語の配信を100配信ずつ(仕様上最大)取得
                param_["offset"] = (i * OFFSET).ToString();
                string json = MyUtility.RemoveSpecialChars(await new MyHttpClient().GetStringAsync(url_, param_));
                using (XmlDictionaryReader reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(json), XmlDictionaryReaderQuotas.Max))
                {
                    XDocument xDocument = XDocument.Load(reader);

                    result.AddRange((from item in xDocument.Root.Element("streams").Elements("item")
                                     let channel = item.Element("channel")
                                                   let owner = channel.Element("name").Value
                                                               let title = MyUtility.RemoveCRLF(channel.Element("status").Value)
                                                                           let start_time = MyUtility.FormatDate(item.Element("created_at").Value, dateFormat_, isUniversal_)
                                                                                            let url = "https://www.twitch.tv/" + channel.Element("name").Value + '/'
                                                                                                      let listener = MyUtility.TryParseOrDefault <string, int>(int.TryParse, item.Element("viewers").Value)
                                                                                                                     where !result.Exists(x => x.Owner == owner)
                                                                                                                     select new StreamClass(title, url, owner, listener, start_time)).ToList());

                    ////配信がなくなったらループを抜ける
                    if (xDocument.Root.Element("streams").Elements("item").Count() < OFFSET)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
示例#11
0
 private void btnTenPhong_Properties_ClearButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     MyUtility.ClearButtonEditText(sender);
 }
示例#12
0
    /// <summary>
    /// 接触チェック
    /// </summary>
    public void CheckTouch()
    {
        Transform parent = transform.parent;

        if (MyUtility.NullCheck(parent))
        {
            return;
        }

        RockBlock rockBlock = parent.GetComponent <RockBlock>();

        if (MyUtility.NullCheck(rockBlock))
        {
            return;
        }

        List <RockBlockPart> rockBlockParts = rockBlock.rockBlockParts;

        if (MyUtility.NullCheck(rockBlockParts))
        {
            return;
        }

        Transform[] rotationPoints = rockBlock.rotationPoints;
        if (MyUtility.NullCheck(rotationPoints))
        {
            return;
        }

        int iRotationPointCount = rotationPoints.Length;

        RaycastHit2D[][] hitAlls =
        {
            Physics2D.RaycastAll(transform.position, Vector3.right),
            Physics2D.RaycastAll(transform.position, Vector3.left),
            Physics2D.RaycastAll(transform.position, Vector3.up),
            Physics2D.RaycastAll(transform.position, Vector3.down),
        };

        float fReach = GetSize().x / 2;



        foreach (var hitAll in hitAlls)
        {
            foreach (var hit in hitAll)
            {
                if (hit.collider && hit.transform.name.Contains("RockBlockPart"))
                {
                    bool bCheck = false;
                    foreach (var part in rockBlockParts)
                    {
                        if (hit.transform.GetComponent <RockBlockPart>() == part)
                        {
                            bCheck = true;
                        }
                    }
                    if (bCheck)
                    {
                        continue;
                    }



                    float fDistance = Vector3.Distance(hit.point, transform.position);

                    if (Mathf.Abs(fDistance - fReach) <= 0.01f)
                    {
                        Transform otherParent = hit.transform.parent;
                        if (MyUtility.NullCheck(otherParent))
                        {
                            return;
                        }

                        RockBlock otherRockBlock = otherParent.GetComponent <RockBlock>();
                        if (MyUtility.NullCheck(otherRockBlock))
                        {
                            return;
                        }

                        List <RockBlockPart> otherRockBlockParts = otherRockBlock.rockBlockParts;
                        if (MyUtility.NullCheck(otherRockBlockParts))
                        {
                            return;
                        }

                        Transform[] otherRotationPoints = otherRockBlock.rotationPoints;
                        if (MyUtility.NullCheck(otherRotationPoints))
                        {
                            return;
                        }

                        int iOtherRotationPointCount = otherRotationPoints.Length;



                        foreach (var otherPart in otherRockBlockParts)
                        {
                            rockBlockParts.Add(otherPart);
                            otherPart.transform.parent = parent;
                        }



                        Transform[] points =
                            new Transform[iRotationPointCount + iOtherRotationPointCount];

                        for (int i = 0; i < iRotationPointCount; i++)
                        {
                            points[i] = rotationPoints[i];
                        }

                        for (int i = iRotationPointCount; i < iRotationPointCount + iOtherRotationPointCount; i++)
                        {
                            points[i] = otherRotationPoints[i - iRotationPointCount];
                        }



                        Vector3 vec3RotationPointLD = new Vector3(1, 1, 0) * float.MaxValue;
                        Vector3 vec3RotationPointRU = new Vector3(1, 1, 0) * float.MinValue;

                        for (int i = 0; i < points.Length; i++)
                        {
                            Vector3 vec3 = points[i].position;

                            if (vec3.x < vec3RotationPointLD.x)
                            {
                                vec3RotationPointLD.x = vec3.x;
                            }
                            if (vec3.y < vec3RotationPointLD.y)
                            {
                                vec3RotationPointLD.y = vec3.y;
                            }

                            if (vec3.x > vec3RotationPointRU.x)
                            {
                                vec3RotationPointRU.x = vec3.x;
                            }
                            if (vec3.y > vec3RotationPointRU.y)
                            {
                                vec3RotationPointRU.y = vec3.y;
                            }
                        }

                        rockBlock.rotationPoints[0].position = vec3RotationPointLD;
                        rockBlock.rotationPoints[1].position = new Vector3(vec3RotationPointLD.x, vec3RotationPointRU.y);
                        rockBlock.rotationPoints[2].position = vec3RotationPointRU;
                        rockBlock.rotationPoints[3].position = new Vector3(vec3RotationPointRU.x, vec3RotationPointLD.y);



                        Destroy(otherParent.gameObject);



                        rockBlock.rotationPoint =
                            (MyDirection.Left == rockBlock.rotateDirection) ? rockBlock.rotationPoints[1] : rockBlock.rotationPoints[3];



                        rockBlock.state = RockBlockState.STANDBY;
                    }
                }
            }
        }
    }
示例#13
0
    public bool IsCollidedDown()
    {
        Transform parent = transform.parent;

        if (MyUtility.NullCheck(parent))
        {
            return(false);
        }

        RockBlock rockBlock = parent.GetComponent <RockBlock>();

        if (MyUtility.NullCheck(rockBlock))
        {
            return(false);
        }

        List <RockBlockPart> rockBlockParts = rockBlock.rockBlockParts;

        if (MyUtility.NullCheck(rockBlockParts))
        {
            return(false);
        }



        int iLayerMask = (1 << LayerMask.NameToLayer("BackGround")) | (1 << LayerMask.NameToLayer("Cloud"));

        iLayerMask = ~iLayerMask;

        RaycastHit2D hit =
            Physics2D.Raycast(
                transform.position,
                Vector3.down,
                1.0f,
                iLayerMask
                );

        if (hit.collider && !hit.transform.tag.Contains("Player"))
        {
            bool bCheck = false;
            foreach (var part in rockBlockParts)
            {
                if (hit.transform.GetComponent <RockBlockPart>() == part)
                {
                    bCheck = true;
                }
            }
            if (bCheck)
            {
                return(false);
            }



            float fDistance = Vector3.Distance(hit.point, transform.position);
            return(GetSize().y / 2 + 0.1f >= fDistance);
        }



        return(false);
    }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }

            #region ko cho chỉnh sửa giờ nếu khoảng thời gian xem công tồn tại các ngày đã kết lương

            if (XL.Kiemtra(new DateTime(dtpThang.Value.Year, dtpThang.Value.Month, 1), new DateTime(dtpThang.Value.Year, dtpThang.Value.Month, DateTime.DaysInMonth(dtpThang.Value.Year, dtpThang.Value.Month))))
            {
                MessageBox.Show(string.Format(Resources.Text_KhoangTGDaKetCong_KoChinhSuaGioCC, "khai báo chấm công cho quản lý", "khai báo chấm công", ""),
                                Resources.Caption_ThongBao, MessageBoxButtons.OK);
                return;
            }

            #endregion


            #region lấy và kiểm tra dsnv được chọn

            BindingContext[dgrdDSNVTrgPhg.DataSource].EndCurrentEdit();
            //2. lấy danh sách nhân viên check, nếu chưa có nv nào check thì thông báo
            var listNV = (from DataGridViewRow dataGridViewRow in dgrdDSNVTrgPhg.Rows
                          let rowView = dataGridViewRow.DataBoundItem as DataRowView
                                        where (rowView["check"] != DBNull.Value && (bool)rowView["check"])
                                        select((cUserInfo)rowView["cUserInfo"]))
                         .ToArray();

            if (listNV.Length == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaChonNV, Resources.Caption_ThongBao, 2000);                 //
                GC.Collect();
            }

            #endregion

            #region lấy ds các ngày đã check

            var DSNgayCheck = (from object item in checklistNgay.CheckedItems select(DateTime) item).ToList();
            if (DSNgayCheck.Count == 0)
            {
                ACMessageBox.Show("Bạn chưa chọn ngày làm việc.", "Thông báo", 2000);
                return;
            }

            #endregion

            #region lấy thông tin

            var      ngay1      = DateTime.Today.Date;
            TimeSpan TimeSpanBD = dtpBDLam.Value.TimeOfDay;
            TimeSpan TimeSpanKT = dtpKTLam.Value.TimeOfDay;
            var      timeBD     = ngay1.Add(TimeSpanBD);
            var      timeKT     = ngay1.Add(TimeSpanKT);
            if (TimeSpanBD > TimeSpanKT)
            {
                timeKT = timeKT.AddDays(1d);
            }
            //var sophutOT = (checkXNLamThem.Checked && numSoPhutOT.Value > 0) ? (int)numSoPhutOT.Value : 0;
            TimeSpan OTCa = TimeSpan.Zero;            //ver 4.0.0.4
            if (checkXNLamThem.Checked && TimeSpan.TryParseExact(maskPhutTinhLamThem.Text, @"hh\:mm", CultureInfo.InvariantCulture, out OTCa) == false)
            {
                ACMessageBox.Show(Resources.Text_NhapThoiGianLamThemChuaHopLe, Resources.Caption_Loi, 2000);
                return;
            }
            var    sophutOT    = Convert.ToInt32(OTCa.TotalMinutes);  //ver 4.0.0.4
            var    TinhPCTC    = (checkTinhPC150.Checked);
            var    bVaoTreLaCV = checkXNVaoTreTinhCV.Checked;         //ver 4.0.0.4
            var    bRaaSomLaCV = checkXNRaaSomTinhCV.Checked;         //ver 4.0.0.4
            string lydo        = (cbLyDo.SelectedItem != null) ? cbLyDo.SelectedItem.ToString() : cbLyDo.Text;
            string ghichu      = tbGhiChu.Text;

            #endregion

            #region hỏi lại trước khi thực hiện

            if (MessageBox.Show(Resources.Text_XacNhanThemChamCongTayChoQL, Resources.Caption_XacNhan, MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            #endregion

            try
            {
                var ca = (tbCa.Tag == null) ? null : (cCa)tbCa.Tag;
                foreach (var nv in listNV)
                {
                    foreach (var ngay in DSNgayCheck)
                    {
                        DateTime TimeStrInn = ngay.Date.Add(TimeSpanBD);
                        DateTime TimeStrOut = ngay.Date.Add(TimeSpanKT);
                        if (TimeSpanBD > TimeSpanKT)
                        {
                            TimeStrOut = TimeStrOut.AddDays(1d);
                        }

                        if (ca.QuaDem && TimeSpanBD < TimeSpanKT && TimeSpanBD < XL2._04h30)
                        {
                            TimeStrInn = TimeStrInn.AddDays(1d);
                            TimeStrOut = TimeStrOut.AddDays(1d);
                        }

/*
 *                                              if (ca.ID == int.MinValue)
 *                                                      XL.TaoCaTuDo(ca, TimeStrInn, XL2._08gio, XL2.ChoPhepTre, XL2.ChoPhepSom, XL2.LamThemAfterOT, 1f, "8");
 *                                              else if (ca.ID == int.MinValue + 1)
 *                                                      XL.TaoCaTuDo(ca, TimeStrInn, XL2._12gio, XL2.ChoPhepTre, XL2.ChoPhepSom, XL2.LamThemAfterOT, 1.5f, "D");
 */
                        if (ca.ID < int.MinValue + 100)
                        {
                            XL.TaoCaTuDo(ca, TimeStrInn);                                                    //ver 4.0.0.4
                        }
                        bool match = XL.KiemtraThuocCa(TimeStrInn, TimeStrOut, ngay, ca);
                        // trường hợp chỉ chấm công bình thường thì chỉ thêm giờ cho đơn giản
                        // các trường hợp xác nhận làm thêm x phút thì chuyển sang xác nhận
                        if (ca.ID < 0)
                        {
                            DAO.ThemGioChoNV(nv.MaCC, TimeStrInn, "I", 21, lydo, ghichu);
                            DAO.ThemGioChoNV(nv.MaCC, TimeStrOut, "O", 22, lydo, ghichu);
                            XL.XacNhan_CIO_A(nv.MaCC, TimeStrInn, TimeStrOut, ca, false, false, sophutOT, TinhPCTC, lydo, ghichu,
                                             bVaoTreLaCV, bRaaSomLaCV);
                        }
                        else if (ca.IsExtended || sophutOT > 0 || match == false)
                        {
                            // các trường hợp phải xác nhận là ca tự do, ca mở rộng, ca có làm thêm và giờ nhập ko nằm trong khoảng nhận diện
                            if (ca.TachCaDem)
                            {
                                var timeOutCa3 = ngay.Add(ca.catruoc.Duty.Off);
                                var timeInnCa1 = ngay.AddDays(1d).Add(ca.casauuu.Duty.Onn).Add(XL2._01giay);
                                DAO.ThemGioChoNV(nv.MaCC, TimeStrInn, "I", 21, lydo, ghichu);
                                DAO.ThemGioChoNV(nv.MaCC, timeOutCa3, "O", 22, "Hệ thống tự động thêm giờ đệm tách ca qua ngày", "Thực hiện tự động");
                                DAO.ThemGioChoNV(nv.MaCC, timeInnCa1, "I", 21, "Hệ thống tự động thêm giờ đệm tách ca qua ngày", "Thực hiện tự động");
                                DAO.ThemGioChoNV(nv.MaCC, TimeStrOut, "O", 22, lydo, ghichu);
                                XL.XacNhan_CIO_A(nv.MaCC, TimeStrInn, timeOutCa3, ca.catruoc, false, false, 0, TinhPCTC, lydo, ghichu,
                                                 bVaoTreLaCV, bRaaSomLaCV);                       //ver 4.0.0.4
                                XL.XacNhan_CIO_A(nv.MaCC, timeInnCa1, TimeStrOut, ca.casauuu, false, false, sophutOT, TinhPCTC, lydo, ghichu,
                                                 bVaoTreLaCV, bRaaSomLaCV);                       //ver 4.0.0.4
                            }
                            else
                            {
                                DAO.ThemGioChoNV(nv.MaCC, TimeStrInn, "I", 21, lydo, ghichu);
                                DAO.ThemGioChoNV(nv.MaCC, TimeStrOut, "O", 22, lydo, ghichu);
                                XL.XacNhan_CIO_A(nv.MaCC, TimeStrInn, TimeStrOut, ca, false, false, sophutOT, TinhPCTC, lydo, ghichu,
                                                 bVaoTreLaCV, bRaaSomLaCV);                       //ver 4.0.0.4
                            }
                        }
                        else
                        {
                            DAO.ThemGioChoNV(nv.MaCC, TimeStrInn, "I", 21, lydo, ghichu);
                            DAO.ThemGioChoNV(nv.MaCC, TimeStrOut, "O", 22, lydo, ghichu);
                        }
                    }
                }
                MyUtility.CheckedCheckBox(false, chkAllWKDays, chkAddSat, chkAddSun);                //ver 4.0.0.4
                ACMessageBox.Show("Đã thêm giờ chấm công cho quản lý.", Resources.Caption_ThongBao, 2000);
            }
            catch (Exception ex)
            {
                lg.Error(string.Format("[{0}]_[{1}]\n", this.Name, System.Reflection.MethodBase.GetCurrentMethod().Name), ex);
                MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
            }
        }
示例#15
0
 public void IsGoingUp()
 {
     MyUtility.SetRotationZ(direction, 0f);
 }
示例#16
0
    public static void AddProteinIngredient(JSONNode ingredientDictionary, params string[] pathElements)
    {
        var name    = ingredientDictionary["name"];
        var path    = MyUtility.GetUrlPath(pathElements.ToList(), name);
        var biomt   = (bool)ingredientDictionary["source"]["biomt"].AsBool;
        var center  = (bool)ingredientDictionary["source"]["transform"]["center"].AsBool;
        var pdbName = ingredientDictionary["source"]["pdb"].Value.Replace(".pdb", "");

        List <Vector4>   atomSpheres;
        List <Matrix4x4> biomtTransforms     = new List <Matrix4x4>();
        Vector3          biomtCenter         = Vector3.zero;
        bool             containsACarbonOnly = false;
        bool             oneLOD = false;

        if ((pdbName == "") || (pdbName == "null") || (pdbName == "None") || pdbName.StartsWith("EMDB"))
        {
            return;

            ////check for sphere file//information in the file. if not in file is it on disk ? on repo ?
            ////possibly read the actuall recipe definition ?
            ////check if bin exist
            //var filePath = PdbLoader.DefaultPdbDirectory + ingredientDictionary["name"] + ".bin";
            //if (File.Exists(filePath)){
            //	atomSpheres = new List<Vector4>();
            //	var points = MyUtility.ReadBytesAsFloats(filePath);
            //	for (var i = 0; i < points.Length; i += 4) {
            //		var currentAtom = new Vector4 (points [i], points [i + 1], points [i + 2], points [i + 3]);
            //		atomSpheres.Add (currentAtom);
            //	}
            //	containsACarbonOnly = true;
            //	oneLOD = true;
            //}
            //else if (ingredientDictionary ["radii"] != null) {
            //	atomSpheres = MyUtility.gatherSphereTree(ingredientDictionary)[0];
            //	Debug.Log ("nbprim "+atomSpheres.Count.ToString());//one sphere
            //	oneLOD = true;
            //} else {
            //	float radius = 30.0f;
            //	if (name.Contains("dLDL"))
            //		radius = 108.08f;//or use the mesh? or make sphere from the mesh ?
            //	if (name.Contains("iLDL"))
            //		radius = 105.41f;//or use the mesh? or make sphere from the mesh ?
            //	atomSpheres = new List<Vector4>();
            //	atomSpheres.Add (new Vector4(0,0,0,radius));
            //	//No LOD since only one sphere
            //	oneLOD = true;
            //}
        }
        else
        {
            //if (pdbName.StartsWith("EMDB")) return;
            //if (pdbName.Contains("1PI7_1vpu_biounit")) return;//??
            // Load atom set from pdb file
            var atomSet = PdbLoader.LoadAtomSet(pdbName);

            // If the set is empty return
            if (atomSet.Count == 0)
            {
                return;
            }

            atomSpheres         = AtomHelper.GetAtomSpheres(atomSet);
            containsACarbonOnly = AtomHelper.ContainsCarbonAlphaOnly(atomSet);
        }
        var centerPosition = AtomHelper.ComputeBounds(atomSpheres).center;

        // Center atoms
        AtomHelper.OffsetSpheres(ref atomSpheres, centerPosition);

        // Compute bounds
        var bounds = AtomHelper.ComputeBounds(atomSpheres);

        biomtTransforms = biomt ? PdbLoader.LoadBiomtTransforms(pdbName) : new List <Matrix4x4>();
        biomtCenter     = AtomHelper.GetBiomtCenter(biomtTransforms, centerPosition);

        //if (!pdbName.Contains("1TWT_1TWV")) return;

        // Disable biomts until loading problem is resolved
        //if (!biomt) return;


        // Get ingredient color
        // TODO: Move color palette code into dedicated function
        var cid = ColorPaletteGenerator.GetRandomUniqFromSample(current_color, usedColors[current_color]);

        usedColors[current_color].Add(cid);
        var sample = ColorPaletteGenerator.colorSamples[cid];
        var c      = ColorPaletteGenerator.lab2rgb(sample) / 255.0f;
        var color  = new Color(c[0], c[1], c[2]);

        // Define cluster decimation levels
        var clusterLevels = (containsACarbonOnly)
                ? new List <float>()
        {
            0.85f, 0.25f, 0.1f
        }
            : new List <float>()
        {
            0.15f, 0.10f, 0.05f
        };

        if (oneLOD)
        {
            clusterLevels = new List <float> ()
            {
                1, 1, 1
            }
        }
        ;
        // Add ingredient type
        //SceneManager.Instance.AddIngredient(name, bounds, atomSpheres, color);

        SceneManager.Get.AddProteinIngredient(path, bounds, atomSpheres, color, clusterLevels, oneLOD);
        int instanceCount = 0;

        for (int k = 0; k < ingredientDictionary["results"].Count; k++)
        {
            var p = ingredientDictionary["results"][k][0];
            var r = ingredientDictionary["results"][k][1];

            var position = new Vector3(-p[0].AsFloat, p[1].AsFloat, p[2].AsFloat);
            var rotation = new Quaternion(r[0].AsFloat, r[1].AsFloat, r[2].AsFloat, r[3].AsFloat);

            var mat   = MyUtility.quaternion_matrix(rotation);
            var euler = MyUtility.euler_from_matrix(mat);
            rotation = MyUtility.MayaRotationToUnity(euler);

            if (!biomt)
            {
                // Find centered position
                if (!center)
                {
                    position += MyUtility.QuaternionTransform(rotation, centerPosition);
                }
                SceneManager.Get.AddProteinInstance(path, position, rotation);
                instanceCount++;
            }
            else
            {
                foreach (var transform in biomtTransforms)
                {
                    var biomteuler = MyUtility.euler_from_matrix(transform);
                    var rotBiomt   = MyUtility.MayaRotationToUnity(biomteuler);
                    var offset     = MyUtility.QuaternionTransform(rotBiomt, centerPosition);               //Helper.RotationMatrixToQuaternion(matBiomt), GetCenter());
                    var posBiomt   = new Vector3(-transform.m03, transform.m13, transform.m23) + offset - biomtCenter;

                    var biomtOffset      = MyUtility.RotationMatrixToQuaternion(transform) * centerPosition;
                    var biomtInstanceRot = rotation * rotBiomt;                    //Helper.RotationMatrixToQuaternion(transform);
                    var biomtInstancePos = rotation * posBiomt + position;

                    SceneManager.Get.AddProteinInstance(path, biomtInstancePos, biomtInstanceRot);
                    instanceCount++;
                }
            }
        }

        SceneManager.Get.AddIngredientProperties(atomSpheres.Count, instanceCount);

        Debug.Log("*****");
        Debug.Log("Added ingredient: " + path);

        //if (isCarbonAlphaOnly) Debug.Log("Alpha-carbons only");
        //Debug.Log("Pdb name: " + pdbName + " *** " + "Num atoms: " + atomSet.Count + " *** " + "Num instances: " + instanceCount + " *** " + "Total atom count: " + atomSet.Count * instanceCount);
    }
示例#17
0
 public void Run()
 {
     Main06();
     MyUtility.MyPause("Od poniedziałku do lasu ...");
 }
示例#18
0
        public ActionResult uploaddata(LoginViewModel lvm, FormCollection form)
        {
            try
            {
                UvlotAEntities db = new UvlotAEntities();
                //string refNumber = MyUtility.GenerateRefNo();
                DataTable  dt = (DataTable)Session["myDtVal"];
                DataReader dr = new DataReader();
                GetMenus();
                foreach (DataRow row in dt.Rows)
                {
                    try
                    {
                        //  LoanApplication inst = new LoanApplication();
                        if (row["SURNAME"] != null)
                        {
                            if (row["SURNAME"].ToString().Length < 2 && row["FIRST NAME"].ToString().Length < 2)
                            {
                                break;
                            }
                        }

                        LoanApplication instObj = new LoanApplication();

                        instObj.AccomodationType_FK = dr.GetAccomType(row["ACCOMMODATION TYPE"].ToString());
                        instObj.AccountName         = row["ACCOUNT NAME"].ToString();
                        instObj.AccountNumber       = row["ACCOUNT NUMBER"].ToString();

                        instObj.ApplicantID          = row["MEANS OF ID"].ToString();
                        instObj.ApplicationStatus_FK = 3;//Pending status,
                        instObj.BVN            = row["BANK VERIFICATION NUMBER"].ToString();
                        instObj.ClosestBusStop = row["CLOSEST BUSTOP"].ToString();

                        string DOB = row["DATE OF BIRTH"].ToString();
                        instObj.ContactAddress = row["HOME ADDRESS"].ToString();
                        instObj.CreatedBy      = ""; //Change To User ID

                        instObj.DateCreated = MyUtility.getCurrentLocalDateTime();

                        instObj.DateModified = MyUtility.getCurrentLocalDateTime();
                        instObj.DateOfBirth  = DOB;// Helper.isDate(DOB) == true ? Convert.ToDateTime(DOB) : MyUtility.getCurrentLocalDateTime();
                        instObj.EmailAddress = row["PERSONAL EMAIL"].ToString();
                        instObj.ExistingLoan = row["ANY EXISTING LOAN"].ToString().ToUpper() == "YES" ? true : false;

                        instObj.ExistingLoan_NoOfMonthsLeft = 0;

                        instObj.ExistingLoan_OutstandingAmount = 0;
                        instObj.Firstname = row["FIRST NAME"].ToString();
                        instObj.Gender_FK = row["GENDER"].ToString().ToUpper() == "MALE" ? 1 : 2;

                        instObj.IdentficationNumber = row["IDENTIFICATION NUMBER"].ToString();
                        instObj.Landmark            = row["LANDMARK"].ToString();
                        instObj.LGA_FK     = dr.GetLocalGovt(row["LGA"].ToString());
                        instObj.LoanAmount = Convert.ToDouble(row["LOAN AMOUNT"]);

                        instObj.LoanComment      = "";
                        instObj.LoanRefNumber    = MyUtility.GenerateRefNo();
                        instObj.MaritalStatus_FK = dr.GetStatus(row["MARITAL STATUS"].ToString());
                        instObj.BankCode         = Convert.ToString(dr.GetBankCode(row["BANK NAME"].ToString().Trim()));
                        instObj.MeansOfID_FK     = dr.GetMeansofIdbyname(row["MEANS OF ID"].ToString());

                        instObj.NOK_EmailAddress = row["NOK_EMAIL ADDRESS"].ToString();
                        instObj.NOK_FullName     = row["NOK_NAME"].ToString();
                        instObj.NOK_HomeAddress  = row["NOK_HOME ADDRESS"].ToString();
                        instObj.NOK_PhoneNumber  = row["NOK_PHONE"].ToString();


                        instObj.NOK_Relationship = row["NOK_RELATIONSHIP"].ToString();
                        instObj.Organization     = row["EMPLOYER"].ToString();
                        instObj.Othernames       = "";
                        instObj.PhoneNumber      = row["MOBILE NUMBER"].ToString();

                        instObj.Institution_FK      = dr.GetInstitution(row["INSTITUTION"].ToString());
                        instObj.RepaymentMethod_FK  = 0;
                        instObj.StateofResidence_FK = dr.GetState(row["STATE OF RESIDENCE"].ToString());
                        instObj.Surname             = row["SURNAME"].ToString();
                        instObj.Title_FK            = dr.GetTitleIDByName(row["TITLE"].ToString());

                        instObj.IsVisible = 1;
                        instObj.ValueDate = MyUtility.getCurrentLocalDateTime().ToString("yyyy/MM/dd");
                        instObj.ValueTime = MyUtility.getCurrentLocalDateTime().ToString("H:mmss");
                        db.LoanApplications.Add(instObj);
                        db.SaveChanges();


                        EmployerLoanDetail empObj = new EmployerLoanDetail();
                        empObj.ClosestBusStop = row["CLOSEST BUSTOP"].ToString();
                        empObj.DateCreated    = MyUtility.getCurrentLocalDateTime();
                        empObj.DateModified   = MyUtility.getCurrentLocalDateTime();

                        empObj.Department          = row["DEPARTMENT"].ToString();
                        empObj.Designation         = row["DESIGNATION"].ToString();
                        empObj.EmployerID          = row["EMPLOYEE ID"].ToString();
                        empObj.EmploymentStatus_FK = dr.GetEmpoStatus(row["EMPLOYMENT STATUS"].ToString());

                        empObj.IsVisible = 1;
                        empObj.LandMark  = row["LANDMARK"].ToString();
                        var loss = row["LENGTH OF SERVICE WITH CURRENT EMPLOYER"].ToString();
                        int los  = Helper.isNumeric(loss) == true?Convert.ToInt16(loss) : 0;

                        empObj.LengthOfServiceInMth = los;
                        empObj.LGA_FK           = row["LGA"].ToString();
                        empObj.NetMonthlyIncome = Convert.ToDouble(row["NET MONTHLY INCOME"]);
                        empObj.Occupation       = row["OCCUPATION"].ToString();

                        empObj.OfficialEmailAddress = row["EMAIL"].ToString();
                        empObj.ValueDate            = MyUtility.getCurrentLocalDateTime().ToString("yyyy/MM/dd");
                        empObj.ValueTime            = MyUtility.getCurrentLocalDateTime().ToString("H:mmss");
                        empObj.LoanApplication_FK   = instObj.ID;

                        db.EmployerLoanDetails.Add(empObj);
                        db.SaveChanges();



                        LoanLedger lonObj = new LoanLedger();
                        lonObj.ApplicantID = row["EMPLOYEE ID"].ToString();
                        lonObj.Credit      = 0;
                        lonObj.Debit       = 0;

                        lonObj.Institution_FK = instObj.Institution_FK;
                        lonObj.IsVisible      = 1;
                        lonObj.LastUpdated    = MyUtility.getCurrentLocalDateTime();
                        lonObj.RefNumber      = instObj.LoanRefNumber;

                        lonObj.PartnerRefNumber = "";
                        lonObj.TranxDate        = MyUtility.getCurrentLocalDateTime();
                        lonObj.ValueDate        = MyUtility.getCurrentLocalDateTime().ToString("yyyy/MM/dd");
                        lonObj.ValueTime        = MyUtility.getCurrentLocalDateTime().ToString("H:mmss");

                        db.LoanLedgers.Add(lonObj);
                        db.SaveChanges();

                        //DataWriter.CreateLoanApplication(instObj);
                    }

                    catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                    {
                        Exception raise = dbEx;
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage);
                                //raise a new exception inserting the current one as the InnerException
                                raise = new InvalidOperationException(message, raise);
                            }
                        }
                        WebLog.Log(raise);
                    }
                }
            }


            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage);
                        //raise a new exception inserting the current one as the InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                WebLog.Log(raise);
            }

            return(View("ImportExcel1"));
        }
示例#19
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string maNV = string.Empty;

        if (!MyUtility.TextBoxHopLe(txtMaNV, out maNV))
        {
            lblThongBao.Text = ThongBao.BatBuoc;
            return;
        }
        string hoTen = string.Empty;

        if (!MyUtility.TextBoxHopLe(txtHoTen, out hoTen))
        {
            lblThongBao.Text = ThongBao.BatBuoc;
            return;
        }
        DateTime ns = new DateTime();

        if (!DateTime.TryParseExact(txtNgaySinh.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, out ns))
        {
            lblThongBao.Text = ThongBao.NgayKhongDung;
            return;
        }
        if (!MyUtility.MatKhauTrungKhop(txtPass.Text, txtRetype.Text))
        {
            lblThongBao.Text = ThongBao.MatKhauKhongTrung;
            return;
        }
        ;
        //lay thong tin:
        NhanVien nv = new NhanVien()
        {
            MaNV      = maNV,
            HoTen     = hoTen.ToProper(),
            MaVTCV    = int.Parse(ddlVTCV.SelectedValue),
            GioiTinh  = rblGT.SelectedValue == "1" ? true : false,
            NgaySinh  = ns,
            Email     = txtEmail.Text,
            DienThoai = txtDT.Text,
            TrangThai = rblTT.SelectedValue == "1" ? true : false,
            MatKhau   = txtPass.Text,
            MaVT      = int.Parse(ddlVaiTro.SelectedValue),
            MaCM      = int.Parse(ddlChuyenMon.SelectedValue)
        };

        //them nhan vien:
        //luu hinh nhan vien neu co:
        if (fulProfile.HasFile)
        {
            string extension = string.Empty;
            if (!MyUtility.FileHinhHopLe(fulProfile, out extension))
            {
                lblThongBao.Text = ThongBao.HinhKhongHoLe;
                return;
            }

            if (MyUtility.LuuHinh(fulProfile, string.Format(@"~/images/NhanVien/{0}.{1}", nv.MaNV, extension)))
            {
                nv.Hinh = string.Format("{0}.{1}", nv.MaNV, extension);
            }
        }
        if (!kho.ThemNhanVien(nv) || !kho.Luu())
        {
            lblThongBao.Text = ThongBao.ThemKhongThanhCong;
            return;
        }
        this.LoadTTNV();
        lblThongBao.Text = ThongBao.ThanhCong;
    }
示例#20
0
 public void Run()
 {
     Main03();
     MyUtility.MyPause("I'm programming in the rain ...\nI'm happy again ...");
 }
示例#21
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!MyUtility.ChuoiHopLe(txtTenDV.Text))
        {
            lblKQDV.Text = ThongBao.BatBuoc;
            return;
        }

        DonVi dv = new DonVi()
        {
            TenDV     = txtTenDV.Text,
            TenDVEN   = string.Empty,
            DienThoai = txtDT.Text,
            DiaChi    = txtDC.Text,
            Email     = txtEmail.Text,
            Fax       = txtFax.Text,
            TrangThai = true,
            Logo      = string.Empty,
            Website   = txtWebsite.Text
        };

        //neu co logo:
        if (fulLogo.HasFile)
        {
            string exten;
            if (!MyUtility.FileHinhHopLe(fulLogo, out exten))
            {
                lblKQDV.Text = ThongBao.HinhKhongHoLe;
                return;
            }
            var virPath = @"~/images/LogoDV/" + dv.MaDV + "." + exten;
            if (MyUtility.LuuHinh(fulLogo, virPath))
            {
                dv.Logo = dv.MaDV + "." + exten;
            }
        }
        if (!kho.ThemDonVi(dv))
        {
            lblKQDV.Text = ThongBao.ThemKhongThanhCong;
            return;
        }
        if (!kho.Luu())
        {
            lblKQDV.Text = ThongBao.ThemKhongThanhCong;
            return;
        }
        else
        {
            //neu co logo:
            if (fulLogo.HasFile)
            {
                string exten;
                if (!MyUtility.FileHinhHopLe(fulLogo, out exten))
                {
                    lblKQDV.Text = ThongBao.HinhKhongHoLe;
                    return;
                }
                var virPath = @"~/images/LogoDV/" + dv.MaDV + "." + exten;
                if (MyUtility.LuuHinh(fulLogo, virPath))
                {
                    dv.Logo = dv.MaDV + "." + exten;
                    if (!kho.Luu())
                    {
                        lblKQDV.Text = ThongBao.ThemKhongThanhCong;
                        return;
                    }
                }
            }
            //reload:
            Response.Redirect("~/SuperAdmin/QLDonVi.aspx");
        }
    }
示例#22
0
        public void sendLink(String Email)
        {
            try
            {
                //LoanViewModel lvm = new LoanViewModel();
                //String email = lvm.AccountsModel.Email;
                User users  = new DataAccessLayerT.DataManager.User();
                var  result = _DR.checkEmail(Email);
                WebLog.Log("Email +" + result);
                if (result != null)
                {
                    WebLog.Log("Email +" + result);
                    users.EmailAddress = result;
                    WebLog.Log("Email +" + users.EmailAddress);
                    users.ID = _DR.selectUserIDs(users);
                    WebLog.Log("Email +" + users.ID);
                    if (users.ID != 0)
                    {
                        string encrypt = "";
                        try
                        {
                            encrypt = $"tK_{ Classes.Utility.RandomString(30).ToUpper()}" + users.ID;
                            users   = _DR.getUser(Email);
                            WebLog.Log("users +" + users.EmailAddress);
                            string resetLink = ConfigurationManager.AppSettings["ResetPasswordLink"] + encrypt;
                            WebLog.Log("resetLink +" + resetLink);
                            string resetLink1 = "Click The Following Link:<a href='" + resetLink + "'>'" + resetLink + "'</a> to change your password";
                            WebLog.Log("resetLink1 +" + resetLink1);
                            WebLog.Log("resetLink: " + resetLink);
                            var bodyTxt = System.IO.File.ReadAllText(Server.MapPath("~/EmailNotifications/ResetPasswordEmailNotification.html"));
                            bodyTxt = bodyTxt.Replace("$MerchantName", $"{users.Firstname} {users.Lastname}");
                            bodyTxt = bodyTxt.Replace("$Message", $"{resetLink1}");
                            var msgHeader = $"Reset Your Password";
                            WebLog.Log("resetLink: " + resetLink);

                            WebLog.Log("bodyTxt:" + bodyTxt);

                            var sendMail = NotificationService.SendMail(msgHeader, bodyTxt, users.EmailAddress, null, null);
                            //users.ResetPassword = encrypt;
                            users.Audit = encrypt;
                            // users.DateTim = MyUtility.getCurrentLocalDateTime();

                            users.LastUpdated = MyUtility.getCurrentLocalDateTime();
                            _DM.UpdateUsers(users);
                            TempData["message"] = "Please Check Your Email For Password Reset Link";
                        }
                        catch (Exception ex)
                        {
                            ex.Message.ToString();
                            WebLog.Log(ex.Message.ToString());
                        }
                    }
                    else
                    {
                        TempData["message"] = "Please Try Again";
                    }
                }
                else
                {
                    TempData["message"] = "Account Does Not Exist";
                }
            }
            catch (Exception ex)
            {
                //Response.Write(ex.Message.ToString());
                WebLog.Log(ex.Message.ToString());
            }
        }
 // 敵の残り数から生成間隔を更新する
 private void updateCurrentIntervalTime()
 {
     var rate = (maxRemainedEnemy - currentRemainedEnemy) / (float)maxRemainedEnemy;
     var reverseRate = 1f - rate;
     currentIntervalTime = MyUtility.Interpolate(minIntervalTime, maxIntervalTime, reverseRate);
 }
示例#24
0
        public ActionResult CreateUser(LoanViewModel lvm, FormCollection form)
        {
            GLobalClient cc = new GLobalClient();

            try
            {
                if (lvm != null)
                {
                    string value          = lvm.AccountsModel.Email;
                    string password       = lvm.AccountsModel.pasword;
                    string confirmpass    = lvm.AccountsModel.confirmPassword;
                    bool   validatePass   = ValidatePassword(password, confirmpass);
                    var    EncrypPassword = new CryptographyManager().ComputeHash(password, HashName.SHA256);
                    password = EncrypPassword;
                    lvm.AccountsModel.confirmPassword = password;
                    lvm.AccountsModel.pasword         = password;
                    lvm.AccountsModel.Email           = value;
                    lvm.AccountsModel.Referal         = Convert.ToString(form["Referal"]);

                    if (validatePass == false)
                    {
                        TempData["Message"] = "Password And Confirm Password Must Match";
                    }
                    else if (validatePass == true)
                    {
                        bool val = DataReaders.Validate(value);
                        if (val == true)
                        {
                            TempData["Message"] = "User Already Exist";
                            // return RedirectToAction("Signup", "Home", new { area = "" });
                            ViewBag.channel = db.MarketingChannels;
                            return(View("Signup"));
                        }
                        else if (val == false)
                        {
                            lvm.AccountsModel.Date        = DateTime.Now;
                            lvm.AccountsModel.DateTim     = DateTime.Today;
                            lvm.AccountsModel.isVissibles = 1;
                            // This is For the Api
                            // cc.CreateUser(lvm.AccountsModel);
                            User users = new DataAccess.User();
                            users.confirmPassword = lvm.AccountsModel.confirmPassword;
                            users.pasword         = lvm.AccountsModel.pasword;
                            users.Email           = lvm.AccountsModel.Email;
                            users.Date            = lvm.AccountsModel.Date;
                            users.DateTim         = lvm.AccountsModel.DateTim;
                            users.isVissibles     = lvm.AccountsModel.isVissibles;
                            users.firstname       = lvm.AccountsModel.firstname;
                            users.lastname        = lvm.AccountsModel.lastname;
                            users.Phone           = lvm.AccountsModel.Phone;
                            users.Referal         = lvm.AccountsModel.Referal;
                            //string lastid = "0";
                            //users.MyReferalCode = MyUtility.getReferralCode(lastid);
                            users.ReferralLevel = MyUtility.getRefferalLevel(users.Referal);
                            // users.MyReferalCode =
                            int id = DataCreators.CreateUser(users);

                            var channellist = Request["checkboxName"];
                            if (channellist != null)
                            {
                                string[] arr      = channellist.Split(',');
                                var      chanList = removestring(arr);
                                if (arr.Length > 0)
                                {
                                    for (var i = 0; i < arr.Length; i++)
                                    {
                                        string arrc = Convert.ToString(arr[i]);
                                        insertMarketChannel(arrc, id);
                                    }
                                }
                            }


                            if (id != 0)
                            {
                                string lastid = id.ToString();
                                users.MyReferalCode = MyUtility.getReferralCode(lastid);
                                DataCreators.updatelastID(users);

                                DataAccess.UserRole userroles = new DataAccess.UserRole();
                                userroles.UserId     = id;
                                userroles.RoleId     = Convert.ToInt16(ConfigurationManager.AppSettings["DefaultUser"]);
                                userroles.IsVissible = 1;
                                userroles.dates      = DateTime.Now;
                                DataCreators.InsertUserRoles(userroles);
                                TempData["Message"] = "User Created Succesfully";



                                //For LoggedIn User
                                Session["id"]   = lvm.AccountsModel.Email;
                                Session["User"] = Session["id"];
                                var LoggedInuser = new LogginHelper();
                                user = LoggedInuser.LoggedInUser();
                                SendEmail(lvm);

                                string Regpage = ConfigurationManager.AppSettings["DefaultRegister"];

                                return(Redirect(Regpage));

                                //return RedirectToAction("Index", "Dashboard");
                                //  return RedirectToAction("Dashboard", "Dashboard");
                            }
                            else
                            {
                                TempData["Message"] = "Registration Not Succesful Please Try Again!";
                                ViewBag.channel     = db.MarketingChannels;
                            }
                        }
                    }
                }
                else
                {
                    TempData["Message"] = "Error Creating User";
                    ViewBag.channel     = db.MarketingChannels;
                }
                return(RedirectToAction("Signup", "Home", new { area = "" }));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
        private void XuatBangChiTiet(object sender, WaitWindowEventArgs e)
        {
            string saveFileName = e.Arguments[0].ToString();

            var dsnv          = new List <cUserInfo>();
            var ngaydauthang  = MyUtility.FirstDayOfMonth(m_Thang);
            var ngaycuoithang = MyUtility.LastDayOfMonth(m_Thang);

            #region lấy dữ liệu kết lương để xuất

            var tableKetLuongThang        = DAO.LayKetLuongThang(ngaydauthang);
            var tableThongsoKetluongThang = DAO.LayThongsoKetluongThang(ngaydauthang);
            var tableDSNVChiCongnhatThang = DAO.LayTableCongNhat(ngaydauthang);
            var tableTongLuongCongnhat    = SqlDataAccessHelper.ExecuteQueryString(
                @"select  CAST(SUM (SoNgayCong*DonGiaLuong) as float)  from DSNVChiCongNhatThang where Thang=@Thang",
                new string[] { "@Thang" }, new object[] { ngaydauthang });
            var tongLuongCongnhat  = (tableTongLuongCongnhat.Rows[0][0] != DBNull.Value) ? (double)tableTongLuongCongnhat.Rows[0][0] : 0d;
            var tongLuongDieuchinh = (from DataRow row in tableKetLuongThang.Rows
                                      let luongdieuchinh = (row["LuongDieuChinh"] != DBNull.Value)
                                                                                                                           ? (double)row["LuongDieuChinh"]
                                                                                                                           : 0d
                                                           select luongdieuchinh).Sum();
            var tableKetcongNgay = DAO.LayKetcongNgay(ngaydauthang, ngaycuoithang);
            var tableKetcongCa   = DAO.LayKetcongCa(ngaydauthang, ngaycuoithang);
            var tableXPVang      = DAO.LayTableXPVang(ngaydauthang, ngaycuoithang);
            var tableNgayLe      = DAO.DocNgayLe(ngaydauthang, ngaycuoithang);

            #endregion
            ChuanBiDuLieuXuatLuong(dsnv, ngaydauthang, ngaycuoithang, tableKetLuongThang, tableKetcongNgay, tableKetcongCa, tableXPVang, tableNgayLe, tableDSNVChiCongnhatThang);


            var      @continue = true;
            FileInfo template, fileResult;
            try {
                template = new FileInfo(Settings.Default.pathReportChiTietLuong);
            } catch (Exception ex) {
                if (ex is System.Security.SecurityException || ex is UnauthorizedAccessException)
                {
                    MessageBox.Show(string.Format(Resources.Text_KoCoQuyenTruyCapFileX, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else if (ex is NotSupportedException || ex is PathTooLongException)
                {
                    MessageBox.Show(string.Format(Resources.Text_UnsupportedFile_PathTooLong, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else
                {
                    MessageBox.Show(string.Format(Resources.Text_CoLoi), Resources.Caption_Loi); return;
                }
            }
            try {
                fileResult = new FileInfo(saveFileName);
            } catch (Exception ex) {
                if (ex is System.Security.SecurityException || ex is UnauthorizedAccessException)
                {
                    MessageBox.Show(string.Format(Resources.Text_KoCoQuyenTruyCapFileX, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else if (ex is NotSupportedException || ex is PathTooLongException)
                {
                    MessageBox.Show(string.Format(Resources.Text_UnsupportedFile_PathTooLong, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else
                {
                    MessageBox.Show(string.Format(Resources.Text_CoLoi), Resources.Caption_Loi); return;
                }
            }

            try {
                using (var packageResult = new ExcelPackage(template)) {
                    var workbook = packageResult.Workbook;
                    #region ghi sheet thong so

                    var ws = workbook.Worksheets["ThongSo"];
                    ws.Name = "ThongSo";                     //Setting Sheet's name
                    XL.ExportSheetThongSo1(ws, ngaydauthang, tableThongsoKetluongThang);
                    #endregion

                    #region ghi sheet chi tiết từng ngày công
                    ws      = workbook.Worksheets["BangChiTietNgayCong"];
                    ws.Name = "BangChiTietNgayCong";
                    //XL.ExportSheetChiTietNgayCong1(ws, dsnv);

                    #endregion

                    var ws_Template = workbook.Worksheets["BangChiTietLuong"];
                    XL.ExportSheetChiTietLuong1(ws_Template, dsnv);

                    while (@continue)
                    {
                        try {
                            packageResult.SaveAs(fileResult);
                            @continue = false;
                        } catch (Exception ex) {
                            lg.Error(string.Format("[{0}]_[{1}]\n", this.Name, System.Reflection.MethodBase.GetCurrentMethod().Name), ex);
                            if (ex is IOException)
                            {
                                MessageBox.Show(Resources.Text_FileDangMoBoiUngDungKhac, Resources.Caption_Loi);
                                @continue = true;
                            }
                            else
                            {
                                MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
                                @continue = false;
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                if (ex is System.Security.SecurityException || ex is UnauthorizedAccessException)
                {
                    MessageBox.Show(string.Format(Resources.Text_KoCoQuyenTruyCapFileX, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else if (ex is NotSupportedException || ex is PathTooLongException)
                {
                    MessageBox.Show(string.Format(Resources.Text_UnsupportedFile_PathTooLong, "mẫu xuất báo biểu"), Resources.Caption_Loi); return;
                }
                else if (ex is IOException)
                {
                    MessageBox.Show(Resources.Text_FileDangMoBoiUngDungKhac, Resources.Caption_Loi); return;
                }
                else
                {
                    MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
                    return;
                }
            }
        }
示例#26
0
        public override async Task <List <StreamClass> > DownloadLiveAsync()
        {
            var result = new List <StreamClass>();

            string json = MyUtility.RemoveSpecialChars(await new MyHttpClient().GetStringAsync(url_, null));

            using (XmlDictionaryReader reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(json), XmlDictionaryReaderQuotas.Max))
            {
                XDocument xDocument = XDocument.Load(reader);

                result.AddRange((from item in xDocument.Root.Element("channel").Elements("item")
                                 let owner = item.Element("name").Value
                                             let title = item.Element("title").Value
                                                         let start_time = MyUtility.FormatDate(item.Element("start").Value, dateFormat_, isUniversal_, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None)
                                                                          let url = "http://live.fc2.com/" + item.Element("id").Value + '/'
                                                                                    let listener = MyUtility.TryParseOrDefault <string, int>(int.TryParse, item.Element("count").Value)
                                                                                                   where owner.Trim() != string.Empty && owner != "匿名"
                                                                                                   select new StreamClass(title, url, owner, listener, start_time)).ToList());
            }

            return(result);
        }
示例#27
0
 // Sezione ExistsEatingMove=================================================
 //ritorna se esiste una eatingMove da un certo centro
 private bool ExistsEatingMove(int r, int c)
 {
     //le mosse pari hanno la diagonale
     if ((r + c) % 2 == 0)
     {
         int roundR2 = r - 2;
         while (roundR2 <= r + 2)
         {
             int roundC = c - 2;
             while (roundC <= c + 2)
             {
                 if (!MyUtility.IsPositionOutOfCross(roundR2, roundC))
                 {
                     Move    hypoteticMove = new Move(PawnType.Fox, r, c, roundR2, roundC);
                     Vector2 interpolPawn  = hypoteticMove.InterpolateEatenPawn();
                     // se è una mossa interpolabile
                     if (interpolPawn.x != -1 && interpolPawn.y != -1)
                     {
                         int x = (int)interpolPawn.x;
                         int y = (int)interpolPawn.y;
                         //se sotto la mossa che tento di fare c'è un'oca non posso sovrappormi
                         if (board[hypoteticMove.finalX, hypoteticMove.finalZ] == PawnType.None)
                         {
                             //se sotto l'interpolazione sta un'oca
                             if (board[x, y] == PawnType.Goose)
                             {
                                 return(true);
                             }
                         }
                     }
                 }
                 roundC = roundC + 2;
             }
             roundR2 = roundR2 + 2;
         }
     }
     else
     {
         // le mosse dispari non hanno la diagonale
         for (int roundR = r - 2; roundR <= r + 2; roundR++)
         {
             if (!MyUtility.IsPositionOutOfCross(roundR, c))
             {
                 Move    hypoteticMove = new Move(PawnType.Fox, r, c, roundR, c);
                 Vector2 interpolPawn  = hypoteticMove.InterpolateEatenPawn();
                 // se è una mossa interpolabile
                 if (interpolPawn.x != -1 && interpolPawn.y != -1)
                 {
                     int x = (int)interpolPawn.x;
                     int y = (int)interpolPawn.y;
                     //se sotto la mossa che tento di fare c'è un'oca non posso sovrappormi
                     if (board[hypoteticMove.finalX, hypoteticMove.finalZ] == PawnType.None)
                     {
                         //se sotto l'interpolazione sta un'oca
                         if (board[x, y] == PawnType.Goose)
                         {
                             return(true);
                         }
                     }
                 }
             }
         }
         for (int roundC = c - 2; roundC <= c + 2; roundC++)
         {
             if (!MyUtility.IsPositionOutOfCross(r, roundC))
             {
                 Move    hypoteticMove = new Move(PawnType.Fox, r, c, r, roundC);
                 Vector2 interpolPawn  = hypoteticMove.InterpolateEatenPawn();
                 // se è una mossa interpolabile
                 if (interpolPawn.x != -1 && interpolPawn.y != -1)
                 {
                     int x = (int)interpolPawn.x;
                     int y = (int)interpolPawn.y;
                     //se sotto la mossa che tento di fare c'è un'oca non posso sovrappormi
                     if (board[hypoteticMove.finalX, hypoteticMove.finalZ] == PawnType.None)
                     {
                         //se sotto l'interpolazione sta un'oca
                         if (board[x, y] == PawnType.Goose)
                         {
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     // se tutte le interpolazioni falliscono non esiste una eatingMove
     return(false);
 }
        private void XuatBBKetCongThang(object sender, WaitWindowEventArgs e)
        {
            string saveFileName = (string)e.Arguments[0]; string tenNVLapBieu = (string)e.Arguments[1]; string tenTrgBP = (string)e.Arguments[2];

            #region lấy thông tin từ csdl và khỏi tạo  nv

            int[] listMaCC                  = (from nv in m_dsnv select nv.MaCC).ToArray();
            var   ngaydauthang              = MyUtility.FirstDayOfMonth(dtpThang.Value);
            var   ngaycuoithang             = MyUtility.LastDayOfMonth(dtpThang.Value);
            var   tableKetcongNgay          = DAO5.LayKetcongNgay(ngaydauthang, ngaycuoithang, DSNV: listMaCC);
            var   tableKetcongCa            = DAO5.LayKetcongCa(ngaydauthang, ngaycuoithang, DSNV: listMaCC);
            var   tableXPVang               = DAO5.LayTableXPVang(ngaydauthang, ngaycuoithang, listMaCC);
            var   tableNgayLe               = DAO5.DocNgayLe(ngaydauthang, ngaycuoithang);
            var   tableDSNVChiCongnhatThang = DAO5.LayTableCongNhat(ngaydauthang, DSNV: listMaCC);

            #endregion

            // xác định công chuẩn của tháng
            var soNgayChuNhat  = XL.DemSoNgayNghiChunhat(ngaydauthang, true, false);
            var congChuanThang = DateTime.DaysInMonth(ngaydauthang.Year, ngaydauthang.Month) - soNgayChuNhat;

            #region                    //load cong phu cap tung ngay cho tat ca nv, ke ca cong nhat, rieng truong hop cong nhat se xu ly ngay ben duoi
            List <cUserInfo> dsnv9 = new List <cUserInfo>();
            foreach (var nv in m_dsnv) // duyệt qua các nhân viên được check
            {
                cUserInfo nv9 = new cUserInfo {
                    MaCC         = nv.MaCC, MaNV = nv.MaNV, TenNV = nv.TenNV, ChucVu = nv.ChucVu, IDChucVu = nv.IDChucVu,
                    HeSo         = nv.HeSo, PhongBan = nv.PhongBan, IsUserEnabled = nv.IsUserEnabled, LichTrinhLV = nv.LichTrinhLV,
                    ThongKeThang = new ThongKeCong_PC(), DSNgayCong = new List <cNgayCong>(), DSVang = new List <cLoaiVang>()
                };
                for (DateTime indexNgay = ngaydauthang; indexNgay <= ngaycuoithang; indexNgay = indexNgay.AddDays(1d))
                {
                    XL.LoadNgayCong(nv9.MaCC, nv9.DSNgayCong, indexNgay, tableKetcongNgay, tableKetcongCa);
                }

                XL.LoadDSXPVang_Le(nv.MaCC, tableXPVang, tableNgayLe, nv.DSVang);
                XL.PhanPhoi_DSVang7(nv.DSVang, nv.DSNgayCong);

                XL.LoadThongtinLamViecCongNhat(nv9.MaCC, ref nv9.NgayBDCongnhat, ref nv9.NgayKTCongnhat, ref nv9.LoaiCN, nv9.DSNgayCong, tableDSNVChiCongnhatThang);
                dsnv9.Add(nv9);
            }

            foreach (var nv9 in dsnv9)
            {
                XL.ThongKeThang(ref nv9.ThongKeThang, nv9.DSNgayCong, nv9.NgayBDCongnhat, nv9.NgayKTCongnhat, nv9.LoaiCN);

                // tính công chờ việc: 1.nv công nhật ko cv. 2. nv mới chính thức thì chỉ giữ công cv khai báo
                if (nv9.NgayBDCongnhat != DateTime.MinValue)                 // nhân viên vừa làm chính thức vừa làm công nhật, công cv tự động = 0
                {
                    nv9.ThongKeThang.CongCV_Auto = 0f;
                }
                else                 // nhân viên chính thức
                {
                    nv9.ThongKeThang.CongCV_Auto = congChuanThang -
                                                   /*(nv9.ThongKeThang.Cong + nv9.ThongKeThang.Le + nv9.ThongKeThang.Phep +//ver4.0.0.0*/
                                                   (nv9.ThongKeThang.TongNgayLV + nv9.ThongKeThang.Le + nv9.ThongKeThang.Phep +                                               //ver4.0.0.1
                                                    nv9.ThongKeThang.BHXH + nv9.ThongKeThang.H_CT_PT
                                                    + nv9.ThongKeThang.PTDT + nv9.ThongKeThang.NghiRo + nv9.ThongKeThang.CongCV_KB);                                          //DANGLAM
                    if (nv9.ThongKeThang.CongCV_Auto < 0f)
                    {
                        nv9.ThongKeThang.CongCV_Auto = 0f;
                    }
                }
                nv9.ThongKeThang.CongCV = nv9.ThongKeThang.CongCV_Auto + nv9.ThongKeThang.CongCV_KB;
            }

            #endregion


            using (var p = new ExcelPackage()) {
                //2. xuat bb bang ket cong thang

                #region ghi sheet bang ket cong thang trinh ky

                p.Workbook.Worksheets.Add("BangKetCong");
                var ws = p.Workbook.Worksheets["BangKetCong"];
                ws.Name = "BangKetCong";                 //Setting Sheet's name
                XL.ExportSheetBangKetcongThang(ws, MyUtility.FirstDayOfMonth(dtpThang.Value), MyUtility.LastDayOfMonth(dtpThang.Value),
                                               dsnv9, tenNVLapBieu, tenTrgBP, XL2.PC30, XL2.PC50, XL2.PCTCC3, XL2.PC100, XL2.PC160, XL2.PC200, XL2.PC290);

                #endregion

                //3. xuat bb chi tiết kết công

                #region ghi sheet chi tiết kết công

                p.Workbook.Worksheets.Add("ChiTietKetCong");
                ws      = p.Workbook.Worksheets["ChiTietKetCong"];
                ws.Name = "ChiTietKetCong";                 //Setting Sheet's name
                XL.ExportSheetBangChiTietKetCong(ws, MyUtility.FirstDayOfMonth(dtpThang.Value), MyUtility.LastDayOfMonth(dtpThang.Value),
                                                 dsnv9, XL2.PC30, XL2.PC50, XL2.PCTCC3, XL2.PC100, XL2.PC160, XL2.PC200, XL2.PC290);

                #endregion

                Byte[] bytes = p.GetAsByteArray();
                XL.XuatFileExcel(saveFileName, bytes, "frmXuatBBCongPC XuatBBKetCongThang");
            }
        }
示例#29
0
    private IEnumerator BashCO(float duration)
    {
        bash_      = false;
        isBashing_ = true;
        shieldBashSprite_.SetActive(true);
        ResetForceIn();
        Collider2D[] collidersHit;
        bool         addForce = false;

        while (true)
        {
            collidersHit = Physics2D.OverlapCircleAll(shieldBashSprite_.transform.position,
                                                      (shieldBashSprite_.transform.localScale.x / 2f), layerMask_);

            if (collidersHit.Length > 0)
            {
                //Test if anything we hit shall give us force
                for (int i = 0; i < collidersHit.Length; i++)
                {
                    if (MyUtility.IsInLayerMask(collidersHit[i].gameObject.layer, receiveForceMask_))
                    {
                        addForce = true;
                        i        = collidersHit.Length; //break for loop
                    }
                }

                //Test if we shall give anything we hit force (test for IBashable)
                for (int i = 0; i < collidersHit.Length; i++)
                {
                    if (collidersHit[i].GetComponent <IBashable>() != null)
                    {
                        collidersHit[i].GetComponent <IBashable>().Bashed(transform);
                    }
                }

                //Produce particle effect
                if (bashParticles != null)
                {
                    Instantiate(bashParticles, transform.position + (shield_.up * 0.7f), shield_.rotation);
                }

                break;
            }

            if (duration > 0)
            {
                duration -= Time.deltaTime;
            }
            else
            {
                break;
            }

            yield return(new WaitForFixedUpdate());
        }

        if (addForce)
        {
            rb_.velocity = Vector2.zero;
            rb_.AddForce(-shield_.up.normalized * bashForceIn, ForceMode2D.Impulse);
        }

        yield return(new WaitForSeconds(duration));

        shieldBashSprite_.SetActive(false);
        isBashing_ = false;
    }
示例#30
0
 private void btnEdit_Clear_Click(object sender, EventArgs e)
 {
     MyUtility.ClearButtonEditText(sender);
 }