Exemple #1
0
        /// <summary>
        /// Có hỗ trợ ghi log, phát sinh tự động thietbi hay không ? dựa trên loaichung hay riêng của loaithietbi,
        /// Tự động có transaction
        /// A. Trường hợp thêm Thiết bị vào phòng mà chỉ chọn: Loại thiết bị
        ///
        /// CTThietBi obj = new CTThietBi();
        /// obj.thietbi = ThietBi.request(loaithietbi);
        /// obj.phong = phong;
        /// obj.tinhtrang = tinhtrang;
        /// obj.soluong=soluong;
        /// obj.mota=mota;
        /// obj.hinhanhs = hinhs;
        /// obj.add();
        ///
        /// B. Trường hợp thêm Thiết bị vào phòng chọn được: Thiết bị
        ///
        /// CTThietBi obj = new CTThietBi();
        /// obj.thietbi = thietbi;
        /// obj.phong = phong;
        /// obj.tinhtrang = tinhtrang;
        /// obj.soluong=soluong;
        /// obj.mota=mota;
        /// obj.hinhanh = hinhs;//Hình sạch
        /// obj.add();
        /// </summary>
        /// <returns></returns>
        public override int add()
        {
            try
            {
                this.ngay = this.ngay == null?ServerTimeHelper.getNow() : this.ngay;

                //SCRIPT
                CTThietBi tmp = search(phong, thietbi, tinhtrang);
                //Nếu có CTTB sẵn trùng Phòng, Thiết bị, Tình trạng thì cộng dồn SL vào và update
                if (tmp != null)
                {
                    tmp.soluong += soluong;
                    tmp.ngay     = this.ngay;
                    tmp.mota     = this.mota;
                    tmp.hinhanhs = hinhanhs;
                    //call update on tmp
                    tmp.update();
                    //id = tmp.id;
                }
                else
                {
                    base.add();
                }
                return(1);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(-1);
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Chọn files
            OpenFileDialog x = new OpenFileDialog();

            x.Multiselect = true;
            x.ShowDialog();
            string[] file_names = x.FileNames;
            //Tạo chứng từ mới
            ct        = new ChungTu();
            ct.ngay   = ServerTimeHelper.getNow();
            ct.sohieu = "mã chứng từ";
            //Gán attchment
            foreach (string file_name in file_names)
            {
                Attachment tmp = new Attachment();
                tmp.LOCAL_FILE_PATH = file_name;
                ct.attachments.Add(tmp);
            }
            //register event
            ct.onUploadProgress += new SHARED.Libraries.FTPHelper.UploadProgress(this.onChungTu_Uploading);
            // do in background
            cancel = new CancellationTokenSource();
            var re = ct.upload(cancel.Token).ContinueWith(new Action <Task>(this.onUploadFinish));
        }
        /// <summary>
        /// set LOCAL_FILE_PATH trước: C:\folder\filename.xyz
        /// </summary>
        /// <returns></returns>
        public async Task <int> upload(CancellationToken cancel = new CancellationToken())
        {
            try
            {
                //kiem tra file co ton tai
                if (!FileHelper.isExist(LOCAL_FILE_PATH))
                {
                    return(-1);
                }
                //tao filename tren ftp server
                String ftp_abs_path_tmp = "";
                ftp_abs_path_tmp += ServerTimeHelper.getNow().ToString("HHmmss_ddMMyyyy");
                ftp_abs_path_tmp += "_";
                ftp_abs_path_tmp += FileHelper.getFileName(LOCAL_FILE_PATH);
                //set lai cac thong so cho this
                this.path = ftp_abs_path_tmp;
                this.size = FileHelper.getFileSizeKilobyte(LOCAL_FILE_PATH);
                //generate abs_path
                ftp_abs_path_tmp = Global.remote_setting.ftp_host.getCombinedPath(ftp_abs_path_tmp);
                //upload len host
                var uploader = new FTPHelper();
                uploader.onUploadProgress += new FTPHelper.UploadProgress(this.onOneFileUploading);
                var re = await uploader.uploadFile(LOCAL_FILE_PATH, ftp_abs_path_tmp, Global.remote_setting.ftp_host.USER_NAME, Global.remote_setting.ftp_host.PASS_WORD, cancel);

                //finish
                return(re);
            }catch (Exception e)
            {
                Debug.WriteLine(e);
                return(-1);
            }
        }
 /// <summary>
 /// Goi hien thi len Panel Thong tin chi tiet
 /// </summary>
 /// <param name="objQuanTriVienFilter"></param>
 private void setThongTinChiTiet(QuanTriVien obj)
 {
     try
     {
         if (obj == null)
         {
             return;
         }
         txtMaQuanTriVien.Text       = obj.subId;
         txtTaiKhoanQuanTriVien.Text = obj.username;
         txtTenQuanTriVien.Text      = obj.hoten;
         txtMatKhauQuanTriVien.Text  = txtXacNhanMK.Text = "";
         memoEdit_mota.Text          = obj.mota;
         dateCreated.DateTime        = (DateTime)(obj.date_create == null ? ServerTimeHelper.getNow() : obj.date_create);
         if (obj.group != null)
         {
             lookUpEdit_group.EditValue = obj.group.id;
         }
         editGUI("view");
         dxErrorProvider1.ClearErrors();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setThongTinChiTiet: " + ex.Message);
     }
 }
Exemple #5
0
 private void btnSmtpSendTest_Click(object sender, EventArgs e)
 {
     if (SHARED.Libraries.EmailHelper.sendMail(
             viewCauHinhRemote1.txtSmtpTestEmail.Text,
             "Test email",
             ServerTimeHelper.getNow().ToString(),
             viewCauHinhRemote1.txtSmtpHost.Text,
             StringHelper.toInt(viewCauHinhRemote1.txtSmtpPort.Text),
             viewCauHinhRemote1.cbSmtpUseSSL.Checked,
             viewCauHinhRemote1.txtSmtpUsername.Text,
             viewCauHinhRemote1.txtSmtpPassword.Text
             ) > 0)
     {
         MessageBox.Show("Email được gửi thành công, vui lòng kiểm tra hộp thư đến!");
     }
     else
     {
         MessageBox.Show("Gửi email bị lỗi!");
     }
 }
        /// <summary>
        /// Tạo Group và QuanTriVien mau
        /// </summary>
        internal void forceSeed()
        {
            try
            {
                //DATETIME
                String mota = "Hệ thống tự động tạo";
                //GROUP
                if (this.GROUPS.Where(c => c.ten.ToLower().Equals("root")).Count() <= 0)
                {
                    Group gp = new Group();
                    gp.mota        = mota;
                    gp.date_create = gp.date_modified = ServerTimeHelper.getNow();
                    gp.ten         = "root";
                    gp.subId       = gp.ten;
                    gp.key         = gp.ten;

                    if (this.QUANTRIVIENS.Where(c => c.username.ToLower().Equals("root")).Count() <= 0)
                    {
                        //QUANTRIVIEN
                        QuanTriVien qtv = new QuanTriVien();
                        qtv.date_create = qtv.date_modified = ServerTimeHelper.getNow();
                        qtv.username    = "******";
                        qtv.setPassword(qtv.username); //hashPassword("root") => "2B1ED923B31D1B0990A28C932565156D11F9F7D9"
                        qtv.hoten = "root";
                        qtv.mota  = mota;
                        qtv.subId = qtv.username;
                        qtv.group = gp;
                        this.QUANTRIVIENS.Add(qtv);
                    }
                }

                //final commit
                SaveChanges();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
        public void loadData()
        {
            checkedComboBoxEdit_tinhTrang.Properties.DataSource =
                TinhTrang.getAll();

            //ucTreeLoaiTB2
            ucTreeLoaiTB2.loadData(LoaiThietBi.getAll());
            ucTreeLoaiTB2.Dock = DockStyle.Fill;
            panelLoaiTB.Controls.Clear();
            panelLoaiTB.Controls.Add(ucTreeLoaiTB2);

            checkedComboBoxEdit_coso.Properties.DataSource = null;
            checkedComboBoxEdit_coso.Properties.DataSource = CoSo.getAll();

            //datetime
            dateEdit_to.EditValue = ServerTimeHelper.getNow();

            gridControlThongKe.DataSource = null;

            //checkPermission
            btnOK.Enabled = /*btnPrint.Enabled =*/ simpleButton_View.Enabled = simpleButton_Design.Enabled = Permission.canDo(Permission._THONGKE_INBAOCAO);

            layout.load(gridViewThongKe);
        }
Exemple #8
0
        public override void onBeforeAdded()
        {
            ngaymua = ngaymua == null?ServerTimeHelper.getNow() : ngaymua;

            base.onBeforeAdded();
        }
Exemple #9
0
        /// <summary>
        /// Di chuyển, kết hợp đổi tình trạng,
        /// có hỗ trợ ghi LOG tự động,vd:
        /// CTThietBi obj = CTThietBi.getById(24552);
        /// Phong dich = null;// Phong.getById(1228);
        /// TinhTrang ttr = TinhTrang.getById(3);
        /// int re = obj.dichuyen(dich, ttr, -1, "đổi tình trạng toàn bộ luôn");
        /// </summary>
        /// <param name="dich">Phòng cần di chuyển đến (null nếu chỉ muốn đổi tình trạng)</param>
        /// <param name="ttmoi">Tình trạng cần chuyển sang (null nếu chỉ muốn đổi phòng)</param>
        /// <param name="soluong">Số lượng cần chuyển (mac dinh la -1 (chuyển tất cả))</param>
        /// /// <param name="mota">Mô tả cho quá trình di chuyển</param>
        /// <param name="hinhs">Hình mô tả cho quá trình di chuyển (Hình sạch)</param>
        /// <returns></returns>
        public int dichuyen(Phong dich = null, TinhTrang ttmoi = null, int soluong = -1, String mota = "", List <HinhAnh> hinhs = null, DateTime?ngay = null)
        {
            try
            {
                //pre set data
                dich = dich == null ? this.phong : dich;
                //=> dich co the van se la null (do this.phong có thể là null)
                ttmoi = ttmoi == null ? this.tinhtrang : ttmoi;//tinh trang không thể null
                ngay  = ngay == null?ServerTimeHelper.getNow() : ngay;

                //XÉT ĐIỀU KIỆN
                if
                (
                    //Nếu Không có bất kỳ sự thay đổi nào, phòng và tình trạng giống với this
                    ((dich == null && this.phong == null) || (dich != null && dich.id == this.phong.id)) &&
                    ttmoi.id == this.tinhtrang.id
                )
                {
                    return(-2);
                }
                //kiem tra rang buoc không cho thực thi
                if
                (
                    soluong == 0 || soluong > this.soluong
                )
                {
                    return(-2);
                }
                soluong = soluong < 0 ? this.soluong : soluong;

                //tao hoac cap nhat mot CTTB moi cho PHONG moi (dich)
                //kiem tra co record nao trung với record cần tạo mới (dich, tinhtrang, thietbi) ?
                CTThietBi tmp = search(dich, this.thietbi, ttmoi);

                //NO
                //TAO MOI CTTB => add
                if (tmp == null)
                {
                    tmp           = new CTThietBi();
                    tmp.phong     = dich;
                    tmp.soluong   = soluong;
                    tmp.thietbi   = this.thietbi;
                    tmp.tinhtrang = ttmoi;
                    tmp.mota      = mota;
                    tmp.hinhanhs  = hinhs;
                    tmp.ngay      = ngay;
                    tmp.add();
                }
                else
                {
                    //Đã có CTTB sẵn giống với CTTB cần tạo mới
                    //SELECT CTTB do len => update
                    if (tmp.id != this.id)
                    {
                        tmp.soluong += soluong;
                        tmp.mota     = mota;
                        tmp.hinhanhs = hinhs;
                        tmp.ngay     = ngay;
                        tmp.update();
                    }
                }

                //cap nhat lai so luong cho cái hiện đã bị chuyển
                this.mota     = mota;
                this.soluong -= soluong;
                this.soluong  = this.soluong < 0 ? 0 : this.soluong;//for sure
                this.hinhanhs = hinhs;
                //ghi log thietbi ngay sau khi cap nhat ONLY soluong
                this.update();
                return(1);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(-1);
            }
        }
Exemple #10
0
 /// <summary>
 /// Chạy nghiệp vụ trước khi được thêm vào CSDL
 /// </summary>
 public virtual void onBeforeAdded()
 {
     //time
     date_create = date_modified = (date_create == null) ? ServerTimeHelper.getNow() : date_create;
     doTrigger();
 }
Exemple #11
0
 /// <summary>
 /// Chạy nghiệp vụ trước khi được cập nhật vào CSDL
 /// </summary>
 public virtual void onBeforeUpdated()
 {
     date_modified = ServerTimeHelper.getNow();
     doTrigger();
 }
 private void setDataView()
 {
     try
     {
         dxErrorProviderInfo.ClearErrors();
         if (!function.Equals("view"))
         {
             editGUI("view");
         }
         if (gridViewQTV.RowCount > 0)
         {
             if (gridViewQTV.GetFocusedRow() != null)
             {
                 objQTV = (gridViewQTV.GetFocusedRow() as QuanTriVienHienThi).quantrivien;
                 txtMaQuanTriVien.Text       = objQTV.subId;
                 txtTaiKhoanQuanTriVien.Text = objQTV.username;
                 txtTenQuanTriVien.Text      = objQTV.hoten;
                 txtMatKhauQuanTriVien.Text  = txtXacNhanMK.Text = "";
                 memoEdit_mota.Text          = objQTV.mota;
                 dateCreated.DateTime        = (DateTime)(objQTV.date_create == null ? ServerTimeHelper.getNow() : objQTV.date_create);
                 if (objQTV.group != null)
                 {
                     lookUpEdit_group.EditValue = objQTV.group.id;
                 }
             }
             else
             {
                 clearText();
                 objQTV = new QuanTriVien();
             }
         }
         else
         {
             enableButton(false);
             clearText();
             objQTV = new QuanTriVien();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setDataView: " + ex.Message);
     }
 }