private void butOk_Click(object sender, System.EventArgs e) { if (i_loai == 0) { s_dir = this.thumuc.Text; this.Close(); } else { ttb.upd_thongso(i_nhom, 3, "Sao lưu số liệu", thumuc.Text.ToString().Trim()); backup f; string ip, post, owner, user, database, file, arg, path, tenfile, ngay = DateTime.Now.Day.ToString().PadLeft(2, '0') + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().PadLeft(4, '0') + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0'); path = thumuc.Text + "\\" + ngay + "\\"; file = @"pg_dump.exe"; user = ttb.user; ip = ttb.Maincode("Ip"); post = ttb.Maincode("Post"); owner = ttb.Maincode("UserID"); if (owner == "") { owner = "medisoft"; } database = ttb.Maincode("Database"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } tenfile = user; arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + path + tenfile + ".backup -n " + tenfile + " " + database; f = new backup(file, arg, true); f.Launch(); foreach (DataRow r in ttb.get_data("select * from " + user + ".table where bak=0").Tables[0].Rows) { tenfile = user + r["mmyy"].ToString(); arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + path + tenfile + ".backup -n " + tenfile + " " + database; f = new backup(file, arg, true); f.Launch(); } //zip.AddFiles(thumuc.Text + "\\" + ngay + ".zip", path); //zip.DeleteFiles(path); // zip.DeleteDirectory(path); } }