Esempio n. 1
0
        //public static void ThemField(System.Data.DataTable table1, string valueDefault, Client server,DataTable dtmmyy)
        //{
        //    string mmyy = DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().Substring(2, 2);
        //    string schema = "", table = "";//, field = "", key = "";
        //    Accessdata acc = new Accessdata();
        //    bool done = false;
        //    foreach (DataRow r in dtmmyy.Rows)
        //    {
        //        done = true;
        //        mmyy = r["mmyy"].ToString();
        //        foreach (System.Data.DataRow row in table1.Rows)
        //        {
        //            schema = row["schema"].ToString();
        //            schema = schema.Replace("xxx", mmyy);
        //            table = row["tablename"].ToString();
        //            acc.AlterTable(schema, table, valueDefault, server);
        //        }
        //    }
        //    if (!done)
        //    {
        //        foreach (System.Data.DataRow row in table1.Rows)
        //        {
        //            schema = row["schema"].ToString();
        //            schema = schema.Replace("xxx", mmyy);
        //            table = row["tablename"].ToString();
        //            acc.AlterTable(schema, table, valueDefault, server);
        //        }
        //    }
        //}
        public static void upd_chuyendi(System.Data.DataTable table1, string valueDefault, Client server, DataTable dtmmyy)
        {
            string     mmyy = DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().Substring(2, 2);
            string     schema = "", table = "";//, field = "", key = "";
            Accessdata acc  = new Accessdata();
            bool       done = false;

            foreach (DataRow r in dtmmyy.Rows)
            {
                done = true;
                mmyy = r["mmyy"].ToString();
                foreach (System.Data.DataRow row in table1.Rows)
                {
                    schema = row["schema"].ToString();
                    schema = schema.Replace("xxx", mmyy);
                    table  = row["tablename"].ToString();
                    acc.update(schema, table, valueDefault, server);
                }
            }
            if (!done)
            {
                foreach (System.Data.DataRow row in table1.Rows)
                {
                    schema = row["schema"].ToString();
                    schema = schema.Replace("xxx", mmyy);
                    table  = row["tablename"].ToString();
                    acc.update(schema, table, valueDefault, server);
                }
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            return;

            string xxx = mm.Value.ToString().PadLeft(2, '0') + yy.Value.ToString().Substring(2, 2);

            filter("");
            CurrencyManager cm = (CurrencyManager)BindingContext[dataGridView1.DataSource];
            DataView        dv = (DataView)cm.List;

            foreach (DataRow row in dv.Table.Select("chon='true'", "stt"))
            {
                // Kiểm tra table có peimary key không?
                if (!dal.HasPrimaryKey(row["table_name"].ToString(), row["schema_name"].ToString().Replace("xxx", xxx)))
                {
                    UI.Thongbao.Message("Syn007", 1, row["schema_name"].ToString().Replace("xxx", xxx) + "." + row["table_name"].ToString());
                    return;
                }
                //Kiểm tra foreign key
                if (!kiemtra_foreign_key(row["table_name"].ToString(), row["schema_name"].ToString().Replace("xxx", xxx)))
                {
                    return;
                }
            }
            // xử lý đồng bộ
            try
            {
                string dblink = cbMaytram.SelectedValue.ToString();
                if (dblink != "")
                {
                    foreach (DataRow row in dv.Table.Select("chon='true'", "stt"))
                    {
                        string schema = row["schema_name"].ToString();
                        schema = schema.Replace("xxx", xxx);
                        string table = row["table_name"].ToString();
                        ///Kiểm tra xem schema có tồn tại không?
                        if (dal.bShemaValid(schema))
                        {
                            if (!dal.update(schema + ".syn_" + table + "_from_" + dblink))
                            {
                                dal.upd_Events(DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0'), "auto", "syn_table", dblink, schema, table, DAL.Accessdata.error, "0", Environment.MachineName.ToString(), "??");
                            }
                        }
                    }
                }
            }
            catch {}
        }