zoukankan      html  css  js  c++  java
  • asp.net 使用事务机制

      using (System.Data.Common.DbTransaction traction = context.Connection.BeginTransaction())
                    {
                        try
                        {
                            SRC_DEF_BASELINE_ALART t = new SRC_DEF_BASELINE_ALART();
                            //新添加的SRC_DEF_BASELINE_ALART的ID位已有的加1
                            short i;
                            if (context.SRC_DEF_BASELINE_ALART.Count() > 0)
                            {
                                i = context.SRC_DEF_BASELINE_ALART.Max(p => p.ALERT_ID);
                            }
                            else
                            {
                                i = 0;
                            }
                            t.ALERT_ID = (short)(i + 1);
                            t.ALERT_NAME = "lx";
                            t.DEFINE_PERSON = "zlf";
                            t.DEFINE_TIME = DateTime.Now;
                            t.PROGRESS_LEVEL_1 = short.Parse(TextBoxjdpc1.Text);
                            t.PROGRESS_LEVEL_2 = short.Parse(TextBoxjdpc2.Text);
                            t.PROGRESS_LEVEL_3 = short.Parse(TextBoxjdpc3.Text);
                            t.PROCEDURE_LEVEL_1 = short.Parse(TextBoxgypc1.Text);
                            t.PROCEDURE_LEVEL_2 = short.Parse(TextBoxgypc2.Text);
                            t.PROCEDURE_LEVEL_3 = short.Parse(TextBoxgypc3.Text);
                            t.TEMP_WORK_LEVEL_1 = short.Parse(TextBoxlspc1.Text);
                            t.TEMP_WORK_LEVEL_2 = short.Parse(TextBoxlspc2.Text);
                            t.TEMP_WORK_LEVEL_3 = short.Parse(TextBoxlspc3.Text);
                            t.QUESTION_LIST_LEVEL_1 = short.Parse(TextBoxjswt1.Text);
                            t.QUESTION_LIST_LEVEL_2 = short.Parse(TextBoxjswt2.Text);
                            t.QUESTION_LIST_LEVEL_3 = short.Parse(TextBoxjswt3.Text);
                            t.PROGRESS_DEV_ALERT_METHOD = dropdownProgress.SelectedItem.ToString();
                            context.CreateObjectSet<SRC_DEF_BASELINE_ALART>().AddObject(t);
                            //应用到平台
                            foreach (ListItem item in cblPlatform.Items)
                            {
                                if (item.Selected)
                                {
                                    SRC_DEF_PLATFORM plat = (from p in context.SRC_DEF_PLATFORM
                                                             where p.PLATFORM_NAME == item.Text
                                                             select p).Single();
                                    if (plat.ALERT_ID != null)
                                    {
                                        if (MessageBox.Show("平台:'"+plat.PLATFORM_NAME + "'已经分配到预警X中,是否执行新的预警设置?", "确认信息:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                                        {
                                            plat.ALERT_ID = t.ALERT_ID;
                                        }
                                    }
                                    else
                                    {
                                        plat.ALERT_ID = t.ALERT_ID;
                                    }
                                }
                            }
                            context.SaveChanges(SaveOptions.DetectChangesBeforeSave);
                            traction.Commit();
                            Response.Redirect("mainAlerts.aspx");
                        }
                        catch (Exception ex)
                        {
                            traction.Rollback();
                            throw ex;
                        }
  • 相关阅读:
    RHEL7: How to configure a rc-local service
    安装 jemalloc for mysql
    aws rhel 7 安装GUI ,配置VNC
    官方推荐的MySQL参数设置值
    Linux HugePages及MySQL 大页配置
    Linux Transparent Huge Pages 对 Oracle 的影响
    Linux的Transparent Hugepage与关闭方法
    Linux HugePages 配置与 Oracle 性能关系说明
    How To Change Log Rate Limiting In Linux
    MySQL 8.0窗口函数
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075913.html
Copyright © 2011-2022 走看看