private void btnAddVirman_Click(object sender, RoutedEventArgs e) { if (ucCustomer.selectedComboboxIndex == -1) { MessageBox.Show("Müşteri boş geçilemez", "Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (cbAccountBranch.SelectedIndex == -1) { MessageBox.Show("Şube seçimi yapılmadı", "Message", MessageBoxButton.OK, MessageBoxImage.Error); cbAccountBranch.Focus(); return; } if (dgAccountFirst.SelectedItem == null) { MessageBox.Show("Lütfen paranın çekileceği hesabı seçiniz.", "Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (dgAccountSecond.SelectedItem == null) { MessageBox.Show("Lütfen paranın yatırılacağı hesabı seçiniz..", "Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } AccountContract selectedFirstAccount = dgAccountFirst.SelectedItem as AccountContract; AccountContract selectedSecondAccount = dgAccountSecond.SelectedItem as AccountContract; if (txtVirmanAmount.Text == "") { MessageBox.Show("Tutar boş geçilemez", "Message", MessageBoxButton.OK, MessageBoxImage.Error); txtVirmanAmount.Focus(); return; } else if (Convert.ToDecimal(txtVirmanAmount.Text) > selectedFirstAccount.Balance) { //para çekimi MessageBox.Show("Hesapta yeterli bakiye yok.", "Message", MessageBoxButton.OK, MessageBoxImage.Error); txtVirmanAmount.Focus(); return; } VirmanContract virmanContract = new VirmanContract(); virmanContract.AccountFirstId = selectedFirstAccount.Id; virmanContract.AccountSecondId = selectedSecondAccount.Id; virmanContract.Description = txtVirmanDesc.Text; virmanContract.Amount = Convert.ToDecimal(txtVirmanAmount.Text); virmanContract.Date = dpVirmanDate.SelectedDate.Value; AddVirman(virmanContract); }
private void AddVirman(VirmanContract virmanContract) { var connect = new Connector.Banking.GenericConnect <VirmanResponse>(); var request = new Types.Banking.VirmanRequest(); request.virmanContract = virmanContract; request.MethodName = "AddVirman"; var response = connect.Execute(request); if (response.IsSuccess == true) { MessageBox.Show("Virman işlemi başarılı", "Message", MessageBoxButton.OK, MessageBoxImage.Information); return; } else { MessageBox.Show("Virman işlemi hatalı", "Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
public bool AddVirman(VirmanContract virmanContract) { int index = 0; SqlParameter[] sqlParameters = new SqlParameter[5]; SqlParameter sqlParameter; if (virmanContract.AccountFirstId == 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@AccountFirstId"; sqlParameter.Value = DBNull.Value; sqlParameters[index] = sqlParameter; index++; } else if (virmanContract.AccountFirstId != 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@AccountFirstId"; sqlParameter.Value = virmanContract.AccountFirstId; sqlParameters[index] = sqlParameter; index++; } if (virmanContract.AccountSecondId == 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@AccountSecondId"; sqlParameter.Value = DBNull.Value; sqlParameters[index] = sqlParameter; index++; } else if (virmanContract.AccountSecondId != 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@AccountSecondId"; sqlParameter.Value = virmanContract.AccountSecondId; sqlParameters[index] = sqlParameter; index++; } if (virmanContract.Description == "") { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Description"; sqlParameter.Value = ""; sqlParameters[index] = sqlParameter; index++; } else if (virmanContract.Description != "") { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Description"; sqlParameter.Value = virmanContract.Description; sqlParameters[index] = sqlParameter; index++; } if (virmanContract.Amount == 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Amount"; sqlParameter.Value = DBNull.Value; sqlParameters[index] = sqlParameter; index++; } else if (virmanContract.Amount != 0) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Amount"; sqlParameter.Value = virmanContract.Amount; sqlParameters[index] = sqlParameter; index++; } if (virmanContract.Date == null) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Date"; sqlParameter.Value = DBNull.Value; sqlParameters[index] = sqlParameter; index++; } else if (virmanContract.Date != null) { sqlParameter = new SqlParameter(); sqlParameter.ParameterName = "@Date"; sqlParameter.Value = virmanContract.Date; sqlParameters[index] = sqlParameter; index++; } SqlDataReader dr; dr = dbOperation.SpGetData("acc.ins_virman", sqlParameters); if (dr.HasRows) { return(false); } else { return(true); } }