Example #1
0
        public void Update_20181219()
        {
            DBByHandClose db = new DBByHandClose(Appsetting.conn);
            IDB           d  = db;

            try
            {
                db.Open();
                db.BeginTran();

                string sql = @"create table 测试升级(
	id varchar(20)
)";

                d.ExecuteScalar(sql, null);

                d.ExecuteScalar(" update sys_t_system set sys_var_value='" + Appsetting.versions + "'   where sys_var_id='app_ver' ", null);
                d.ExecuteScalar(" update sys_t_system set sys_var_value='" + Appsetting.versions + "'   where sys_var_id='ser_ver' ", null);
                d.ExecuteScalar(" update sys_t_system set sys_var_value='" + Appsetting.versions + "'   where sys_var_id='db_ver' ", null);

                db.CommitTran();
            }
            catch (Exception ex)
            {
                db.RollBackTran();
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
Example #2
0
        public void UpdateStyleData(List <sys_t_print_style_data> lis)
        {
            DBByHandClose db = new DBByHandClose(Appsetting.conn);

            d = db;
            try
            {
                db.Open();
                db.BeginTran();

                foreach (sys_t_print_style_data data in lis)
                {
                    data.update_time = DateTime.Now;
                    sys_t_print_style_data old_data = d.ExecuteToModel <sys_t_print_style_data>(
                        "select * from sys_t_print_style_data where style_data='" + data.style_data + "'", null);
                    if (old_data == null || string.IsNullOrEmpty(old_data.style_data))
                    {
                        d.Insert(data);
                    }
                    else
                    {
                        if (old_data.update_time < data.update_time)
                        {
                            d.Update(data, "style_data");
                        }
                    }
                }

                db.CommitTran();
            }
            catch (Exception)
            {
                db.RollBackTran();
                throw;
            }
            finally
            {
                db.Close();
            }
        }