private void btnEnableFK_Click(object sender, EventArgs e)
 {
     if (ckbFKSelection.Checked)
     {
         ADUtils.EnableFKConstraint("AD_");
     }
     else
     {
         ADUtils.EnableFKConstraint(null);
     }
 }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Done!");
            string fileName = HttpContext.Current.Server.MapPath("UploadData\\") + context.Request.QueryString["fileName"];
            Stream raw      = context.Request.InputStream;

            if (!string.IsNullOrEmpty(fileName) && raw.Length > 0)
            {
                byte[] b = new byte[raw.Length];
                raw.Read(b, 0, b.Length);
                using (FileStream fs = new FileStream(fileName, FileMode.Create))
                {
                    fs.Write(b, 0, b.Length);
                }

                string tempDir = HttpContext.Current.Server.MapPath("UploadData\\Temp\\");
                if (!System.IO.Directory.Exists(tempDir))
                {
                    System.IO.Directory.CreateDirectory(tempDir);
                }
                foreach (string s in System.IO.Directory.GetFiles(tempDir))
                {
                    System.IO.File.Delete(s);
                }

                Feng.Utils.CompressionHelper.UnzipToFolder(fileName, tempDir);

                ADUtils.DisableFKConstraint();
                foreach (string s in System.IO.Directory.GetFiles(tempDir))
                {
                    ADUtils.ImportFromXmlFile(s);
                    System.IO.File.Delete(s);
                }
                ADUtils.EnableFKConstraint();

                context.Response.ContentType = "text/plain";
                context.Response.Write("Done!");
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Error!");
            }
        }
Exemple #3
0
        private void btnImportYwsj_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.RestoreDirectory = true;
            dlg.Filter           = "Excel Xml(*.xml)|*.xml";
            //saveFileDialog1.Title = "保存";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show("您正在导入数据到数据库,如果有相同的主键,将会替换数据库数据,是否确认?", "确认", MessageBoxButtons.YesNo)
                    == DialogResult.Yes)
                {
                    ADUtils.DisableFKConstraint();

                    ADUtils.ImportFromXmlFile(dlg.FileName);

                    ADUtils.EnableFKConstraint();
                }
            }
        }