Пример #1
0
 private void btnLoadMarkFromFile_Click(object sender, EventArgs e)
 {
     SySal.OperaDb.OperaDbTransaction trans = null;
     try
     {
         frmLoadMarkFromFile lm = new frmLoadMarkFromFile();
         lm.NumberBrick = lvBricks.SelectedItems[0].SubItems[0].Text;
         if (lm.ShowDialog() == DialogResult.OK)
         {
             trans = SySal.OperaDb.Schema.DB.BeginTransaction();
             long nextmark = SySal.OperaDb.Convert.ToInt32(new SySal.OperaDb.OperaDbCommand("SELECT NVL(MAX(ID_MARK),0) FROM TB_TEMPLATEMARKSETS WHERE ID_EVENTBRICK = " + lvBricks.SelectedItems[0].SubItems[0].Text, SySal.OperaDb.Schema.DB, trans).ExecuteScalar()) + 1;
             foreach (SySal.BasicTypes.Vector v in lm.MarkSet.Marks)
             {
                 SySal.OperaDb.Schema.TB_TEMPLATEMARKSETS.Insert(0L, System.Convert.ToInt64(lvBricks.SelectedItems[0].SubItems[0].Text), nextmark++, v.X, v.Y, 1, 1, lm.MarkSet.type.ToString(), (int)v.Z);
             }
             trans.Commit();
             lvBricks.SelectedItems[0].Selected = true;
         }
     }
     catch (Exception x)
     {
         try
         {
             if (trans != null)
             {
                 trans.Rollback();
             }
         }
         catch (Exception) {}
         MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
 private void btnInsertCSMark_Click(object sender, EventArgs e)
 {
     SySal.OperaDb.OperaDbTransaction trans = null;
     try
     {
         frmInsertMarkFromDB im = new frmInsertMarkFromDB();
         im.NumberBrick = lvBricks.SelectedItems[0].SubItems[0].Text;
         if (im.ShowDialog() == DialogResult.OK)
         {
             trans = SySal.OperaDb.Schema.DB.BeginTransaction();
             int nextmark = SySal.OperaDb.Convert.ToInt32(new SySal.OperaDb.OperaDbCommand("SELECT NVL(MAX(ID_MARK) + 1,0) FROM TB_TEMPLATEMARKSETS WHERE ID_EVENTBRICK = " + lvBricks.SelectedItems[0].SubItems[0].Text, SySal.OperaDb.Schema.DB, trans).ExecuteScalar());
             new SySal.OperaDb.OperaDbCommand("INSERT INTO TB_TEMPLATEMARKSETS (ID_EVENTBRICK, ID_MARK, POSX, POSY, MARKROW, MARKCOL, SHAPE, SIDE) (SELECT " + lvBricks.SelectedItems[0].SubItems[0].Text + ",ID_MARK + " + nextmark + ",POSX,POSY,MARKROW,MARKCOL,SHAPE,1 FROM TB_TEMPLATEMARKSETS WHERE ID_EVENTBRICK=" + im.CsBrick + ")", SySal.OperaDb.Schema.DB, trans).ExecuteNonQuery();
             trans.Commit();
             ListViewItem lvi = lvBricks.SelectedItems[0];
             lvi.Selected = false;
             lvi.Selected = true;
         }
     }
     catch (Exception x)
     {
         try
         {
             if (trans != null)
             {
                 trans.Rollback();
             }
         }
         catch (Exception) { }
         MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }