Exemplo n.º 1
0
 public void Display()   // Display Method is a common method to bind the Student details in datagridview after save,update and delete operation perform.
 {
     using (BackUpEntities _entity = new BackUpEntities())
     {
         metroGrid1.DataSource = _entity.FTPs.ToList();
     }
 }
Exemplo n.º 2
0
        public bool SaveFTPDetails(FTP Stu) // calling SaveStudentMethod for insert a new record
        {
            bool result = false;

            using (BackUpEntities _entity = new BackUpEntities())
            {
                _entity.FTPs.Add(Stu);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
Exemplo n.º 3
0
        public bool DeleteFTPDetails(FTP Stu) // DeleteStudentDetails method to delete record from table
        {
            bool result = false;

            using (BackUpEntities _entity = new BackUpEntities())
            {
                FTP _student = _entity.FTPs.Where(x => x.Id == Stu.Id).SingleOrDefault();
                _entity.FTPs.Remove(_student);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
Exemplo n.º 4
0
 private void btnBackupSelect_Click(object sender, EventArgs e)
 {
     using (BackUpEntities _entity = new BackUpEntities())
     {
         int Id   = Int32.Parse(lbID.Text);
         var item = _entity.FTPs.SingleOrDefault(p => p.Id == Id);
         if (item.Type == 1)
         {
             BackupFTP(item);
         }
         if (item.Type == 2)
         {
             BackupMongodb(item);
         }
         Console.WriteLine("backup successfully: " + item.Name);
         MetroMessageBox.Show(this, "backup successfully: " + item.Name, "Sao lưu", MessageBoxButtons.OK, MessageBoxIcon.Information, 100);
     }
 }
Exemplo n.º 5
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     using (BackUpEntities _entity = new BackUpEntities())
     {
         foreach (var item in _entity.FTPs.ToList())
         {
             if (item.Type == 1)
             {
                 BackupFTP(item);
             }
             if (item.Type == 2)
             {
                 BackupMongodb(item);
             }
         }
     }
     Console.WriteLine("Backup successfully");
     MetroMessageBox.Show(this, "Backup successfully", "Sao lưu", MessageBoxButtons.OK, MessageBoxIcon.Information, 100);
 }
Exemplo n.º 6
0
        public bool UpdateFTPDetails(FTP Stu) // UpdateStudentDetails method for update a existing Record
        {
            bool result = false;

            using (BackUpEntities _entity = new BackUpEntities())
            {
                FTP _student = _entity.FTPs.Where(x => x.Id == Stu.Id).SingleOrDefault();
                _student.Name         = Stu.Name;
                _student.UserName     = Stu.UserName;
                _student.Password     = Stu.Password;
                _student.FTPServer    = Stu.FTPServer;
                _student.FolderSave   = Stu.FolderSave;
                _student.Schedule     = Convert.ToInt32(Stu.Schedule);
                _student.Type         = Stu.Type;
                _student.DatabaseName = Stu.DatabaseName;
                _student.StartDT      = Stu.StartDT;
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
Exemplo n.º 7
0
 private void LoadDatabase()
 {
     _backUpEntities = new BackUpEntities();
     _backUpEntities.FTPs.Load();
 }