Exemplo n.º 1
0
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     using (SqlConnection Con = new SqlConnection(FXFW.SqlDB.SqlConStr))
     {
         string Addess = "NULL", Tel = "NULL", Mobil = "NULL", Fax = "NULL", remark = "NULL";
         if (TxtNewAddess.Text.Trim().Length > 0)
         {
             Addess = String.Format("N'{0}'", TxtNewAddess.Text.Trim());
         }
         if (TxtNewTel.Text.Trim().Length > 0)
         {
             Tel = String.Format("N'{0}'", TxtNewTel.Text.Trim());
         }
         if (TxtNewMobil.Text.Trim().Length > 0)
         {
             Mobil = String.Format("N'{0}'", TxtNewMobil.Text.Trim());
         }
         if (TxtNewFax.Text.Trim().Length > 0)
         {
             Fax = String.Format("N'{0}'", TxtNewFax.Text.Trim());
         }
         if (TxtNewremark.Text.Trim().Length > 0)
         {
             remark = String.Format("N'{0}'", TxtNewremark.Text.Trim());
         }
         SqlTransaction Trn = null;
         SqlCommand     Cmd = new SqlCommand("", Con);
         try
         {
             Con.Open();
             Trn             = Con.BeginTransaction();
             Cmd.Transaction = Trn;
             Cmd.CommandText = String.Format(@"INSERT INTO TBL_Accountes (AccountId, AccountTreeId, PairantAccount, AccountDes) VALUES ({0}, {1}, {2}, N'{3}')",
                                             NewAccountId, TxtNewAccountId.Text, Program.AccountIdCustomer, TxtNewName.Text.Trim());
             Cmd.ExecuteNonQuery();
             Cmd.CommandText = String.Format(@"INSERT INTO CustomersSuppliers (PERSONID, PERSON, Addess, Tel, Mobil, Fax, remark, AccountId, PERSONTYPE)
             VALUES ({0}, '{1}', {2}, {3}, {4}, {5}, {6}, {7}, 1)", Program.GetNewID("CustomersSuppliers", "PERSONID"), TxtNewName.Text.Trim(), Addess, Tel, Mobil, Fax, remark, NewAccountId);;
             Cmd.ExecuteNonQuery();
             Trn.Commit();
             TxtNewName.Text   = string.Empty;
             TxtNewAddess.Text = string.Empty;
             TxtNewTel.Text    = string.Empty;
             TxtNewMobil.Text  = string.Empty;
             TxtNewFax.Text    = string.Empty;
             TxtNewremark.Text = string.Empty;
             TxtNewName.Focus();
             LoadData();
             GetNewAccountID();
             MessageBox.Show("تم الاضــــافه", "اضافــــه", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             Trn.Rollback();
             MessageBox.Show(ex.Message);
         }
         Con.Close();
     }
 }
        private async void BtnRename_Click(object sender, RoutedEventArgs e)
        {
            var frameworkElement = e.OriginalSource as FrameworkElement;

            if (frameworkElement?.DataContext is BlobImage datacontext)
            {
                TxtOldName.Text = datacontext.FileName;
                TxtNewName.Text = "New_" + datacontext.FileName;
                TxtNewName.Focus(FocusState.Programmatic);
                await DigRename.ShowAsync();
            }
        }