Esempio n. 1
0
 public static TransactionForm Instance()
 {
     if (_transactionForm == null)
     {
         _transactionForm = new TransactionForm();
     }
     return(_transactionForm);
 }
Esempio n. 2
0
        private void button_trans_insert_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textbox_sno.Text) || string.IsNullOrEmpty(textbox_sname.Text) || string.IsNullOrEmpty(combobox_ssex.Text))
            {
                MessageBox.Show("请检查填写");
                return;
            }

            Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-cn");

            string sno       = textbox_sno.Text.Trim();
            string sname     = textbox_sname.Text.Trim();
            string ssex      = combobox_ssex.Text.Trim();
            string sbirthday = dtpicker_sbirthday.Value.ToShortDateString().Trim();
            string tc        = textbox_tc.Text.Trim();

            string SQL = null;

            if (isEdit)
            {
                if (string.IsNullOrEmpty(old_tc))
                {
                    SQL = string.Format(@"UPDATE {0} SET SNO='{1}',SNAME='{2}',SSEX='{3}',SBIRTHDAY=to_date('{4}','YYYY/MM/DD'),TC={5} WHERE SNO='{6}' AND SNAME='{7}' AND SSEX='{8}'",
                                        DB_TABLE, sno, sname, ssex, sbirthday, tc,
                                        old_sno, old_sname, old_ssex);
                }
                else
                {
                    SQL = string.Format(@"UPDATE {0} SET SNO='{1}',SNAME='{2}',SSEX='{3}',SBIRTHDAY=to_date('{4}','YYYY/MM/DD'),TC={5} WHERE SNO='{6}' AND SNAME='{7}' AND SSEX='{8}' AND TC='{9}'",
                                        DB_TABLE, sno, sname, ssex, sbirthday, tc,
                                        old_sno, old_sname, old_ssex, old_tc);
                }
            }
            if (isInsert)
            {
                if (string.IsNullOrEmpty(tc))
                {
                    SQL = string.Format(@"INSERT INTO {0} (SNO,SNAME,SSEX,SBIRTHDAY) values ('{1}','{2}','{3}',to_date('{4}','YYYY/MM/DD'))", DB_TABLE, sno, sname, ssex, sbirthday);
                }
                else
                {
                    SQL = string.Format(@"INSERT INTO {0} (SNO,SNAME,SSEX,SBIRTHDAY,TC) values ('{1}','{2}','{3}',to_date('{4}','YYYY/MM/DD'),'{5}')", DB_TABLE, sno, sname, ssex, sbirthday, tc);
                }
            }

            TransactionForm.arrayList.Add(SQL);

            Console.WriteLine(SQL);
            if (!TransactionForm.isTransactionFormRunning())
            {
                TransactionForm.Instance().Show();
            }
            UpdTransFormList();

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 3
0
 private void UpdTransFormList()
 {
     if (TransactionForm.isTransactionFormRunning())
     {
         //刷新对应窗体的选择
         Action ad = delegate()
         {
             TransactionForm.Instance().Ref_ListBox();
         };
         TransactionForm.Instance().Invoke(ad);
     }
 }
Esempio n. 4
0
 private void Commit_button_Click(object sender, EventArgs e)
 {
     if (OracleHelper.ExecuteSQL_Tran(arrayList) == 1)
     {
         MessageBox.Show("Success");
         arrayList.Clear();
         _transactionForm = null;
         this.Close();
     }
     else
     {
         MessageBox.Show("Fail");
     }
 }
Esempio n. 5
0
 private void TransactionForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         if (arrayList.Count > 0)
         {
             e.Cancel = true;
             if (MessageBox.Show("你尚有事务未提交\n确认取消?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 arrayList.Clear();
                 _transactionForm = null;
                 this.Close();
             }
         }
         return;
     }
     else
     {
         arrayList.Clear();
         _transactionForm = null;
         this.Close();
     }
 }
Esempio n. 6
0
 private void Cancel_button_Click(object sender, EventArgs e)
 {
     arrayList.Clear();
     _transactionForm = null;
     this.Close();
 }