private void CreateClientButton_Click(object sender, System.Windows.RoutedEventArgs e) { NameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#FFABADB3")); LastNameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#FFABADB3")); try { if (_controller.CheckTextBoxValue(NameBox)) { NameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#CA373E")); throw new Exception("Имя клиента не может быть пустым!"); } if (NameBox.Text.Length < 2) { NameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#CA373E")); throw new Exception("Минимум два символа!"); } if (_controller.CheckTextBoxValue(LastNameBox)) { LastNameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#CA373E")); throw new Exception("Фамилия клиента не может быть пустой!"); } if (LastNameBox.Text.Length < 4) { NameBox.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#CA373E")); throw new Exception("Минимум четыре символа!"); } Models.ClientModel client = null; ClientModelBuilder clientModelBuilder = new ClientModelBuilder(); client = clientModelBuilder .WithId(0) .WithFirstName(NameBox.Text) .WithLastName(LastNameBox.Text) .Source .WithId(SourceComboBox.SelectedIndex) .Build(); _controller.InsertAsync(client); _controller.InfromationMessage("Производится добавления клиента в базу. Пожалуйста, подождите.", 1); } catch (Exception ex) { _controller.InfromationMessage("При добавлении клиента произошла ошибка. Скорее всего входные данные некорректны.", 0); MessageBox.Show(ex.Message, "Ошибка"); } }
////Add Client Details //public int AddClient(Models.ClientModel clientmodel, DataTable dtcustom) //{ // Int32 MasterClientID = 0; // int value = 0; // List<SqlParameter> sqlparam = new List<SqlParameter>(); // sqlparam.Add(new SqlParameter("@ClientId", clientmodel.ClientId)); // sqlparam.Add(new SqlParameter("@ClientName", clientmodel.ClientName)); // sqlparam.Add(new SqlParameter("@StateId", clientmodel.StateId)); // sqlparam.Add(new SqlParameter("@CityId", clientmodel.CityId)); // sqlparam.Add(new SqlParameter("@ClientAddress", clientmodel.ClientAddress)); // sqlparam.Add(new SqlParameter("@PinCode", clientmodel.pinCode)); // sqlparam.Add(new SqlParameter("@WebSite", clientmodel.WebSite)); // sqlparam.Add(new SqlParameter("@ContactNo", clientmodel.ContactNo)); // sqlparam.Add(new SqlParameter("@IP_Address", clientmodel.IP_Address)); // sqlparam.Add(new SqlParameter("@Is_Sat_Working", clientmodel.Is_Sat_Working)); // sqlparam.Add(new SqlParameter("@AddedBy", clientmodel.AddedBy)); // sqlparam.Add(new SqlParameter("@GeneralShift_1", clientmodel.General_Shift1)); // sqlparam.Add(new SqlParameter("@GeneralShift_2", clientmodel.General_Shift2)); // sqlparam.Add(new SqlParameter("@GeneralShift_3", clientmodel.General_Shift3)); // sqlparam.Add(new SqlParameter("@FirstShift", clientmodel.FirstShift)); // sqlparam.Add(new SqlParameter("@SecondShift", clientmodel.SecondShift)); // sqlparam.Add(new SqlParameter("@NightShift", clientmodel.NightShift)); // sqlparam.Add(new SqlParameter("@IsCustomShift", clientmodel.IsCustomShift)); // sqlparam.Add(new SqlParameter("@FlexibleTime", clientmodel.FlexibleTime)); // sqlparam.Add(new SqlParameter("@NoOfOptionalHoliday", clientmodel.optionalholiday)); // sqlparam.Add(new SqlParameter("@Operation", clientmodel.Operation)); // //if (clientmodel.Is_Sat_Working == true) // //{ // sqlparam.Add(new SqlParameter("@IsSat_1", clientmodel.sat1)); // sqlparam.Add(new SqlParameter("@IsSat_2", clientmodel.sat2)); // sqlparam.Add(new SqlParameter("@IsSat_3", clientmodel.sat3)); // sqlparam.Add(new SqlParameter("@IsSat_4", clientmodel.sat4)); // sqlparam.Add(new SqlParameter("@IsSat_5", clientmodel.sat5)); // SqlParameter MasterClientId = new SqlParameter("@ReturnClientId", SqlDbType.Int) // { // Direction = ParameterDirection.Output // }; // SqlParameter succesful = new SqlParameter("@IsSuccessful", SqlDbType.Int) // { // Direction = ParameterDirection.Output // }; // sqlparam.Add(MasterClientId); // // sqlparam.Add(TempClientId); // sqlparam.Add(succesful); // int i = DAL.SQLHelp.ExecuteNonQuery("Usp_UpdateClient", sqlparam); // value = Convert.ToInt32(succesful.Value.ToString()); // if (i != -1 && i != 2) // { // MasterClientID = Convert.ToInt32(MasterClientId.Value.ToString()); // } // //Int32 TempClientID = Convert.ToInt32(TempClientId.Value.ToString()); // bool isApproveAccess = CheckAccess(clientmodel.AddedBy); // if (clientmodel.ClientId == -1) // { // return value; // } // else // { // if (dtcustom.Rows.Count >= 1) // { // if (clientmodel.IsCustomShift == true) // { // if (isApproveAccess == false) // { // DataTable dt = new DataTable(); // dt.Columns.Add(new DataColumn("TempCustomShiftId", typeof(Int32))); // dt.Columns.Add(new DataColumn("TempClientID", typeof(Int32))); // dt.Columns.Add(new DataColumn("CustomShiftName", typeof(string))); // dt.Columns.Add(new DataColumn("StartTime", typeof(string))); // dt.Columns.Add(new DataColumn("EndTime", typeof(string))); // dt.Columns.Add(new DataColumn("TotalHrs", typeof(Int32))); // for (int a = 0; a < dtcustom.Rows.Count; a++) // { // string ShiftName = dtcustom.Rows[a]["ShiftName"].ToString(); // string StartTime = dtcustom.Rows[a]["StartTime"].ToString(); // string EndTime = dtcustom.Rows[a]["EndTime"].ToString(); // int hour = Convert.ToInt32(dtcustom.Rows[a]["Hours"].ToString()); // dt.Rows.Add(1, MasterClientID, ShiftName, StartTime, EndTime, hour); // } // DAL.SQLHelp.CopyToServer("Tbl_Temp_Client_Custom_Shift", dt); // } // else // { // DataTable dt = new DataTable(); // dt.Columns.Add(new DataColumn("CustomShiftId", typeof(int))); // dt.Columns.Add(new DataColumn("CustomShiftName", typeof(string))); // dt.Columns.Add(new DataColumn("ClientId", typeof(string))); // dt.Columns.Add(new DataColumn("StartTime", typeof(string))); // dt.Columns.Add(new DataColumn("EndTime", typeof(string))); // dt.Columns.Add(new DataColumn("TotalHrs", typeof(int))); // for (int a = 0; a < dtcustom.Rows.Count; a++) // { // string ShiftName = dtcustom.Rows[a]["ShiftName"].ToString(); // string StartTime = dtcustom.Rows[a]["StartTime"].ToString(); // string EndTime = dtcustom.Rows[a]["EndTime"].ToString(); // int hour = Convert.ToInt32(dtcustom.Rows[a]["Hours"].ToString()); // dt.Rows.Add(1, ShiftName, MasterClientID, StartTime, EndTime, hour); // } // DAL.SQLHelp.CopyToServer("Tbl_Clients_Custom_Shift", dt); // } // } // } // } // return value; //} //Update Client From Temp Table public int UpdateTempClient(Models.ClientModel client) { List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@PendingClientId", client.tempclientId)); sqlparam.Add(new SqlParameter("@UserId", client.CreatedBy)); sqlparam.Add(new SqlParameter("@Operation", client.Operation)); if (client.Operation == 1) { DataTable dtcustom = GetCustom(client.ClientId); if (dtcustom.Rows.Count > 0) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("CustomShiftId", typeof(int))); dt.Columns.Add(new DataColumn("CustomShiftName", typeof(string))); dt.Columns.Add(new DataColumn("ClientId", typeof(string))); dt.Columns.Add(new DataColumn("StartTime", typeof(string))); dt.Columns.Add(new DataColumn("EndTime", typeof(string))); dt.Columns.Add(new DataColumn("TotalHrs", typeof(int))); for (int a = 0; a < dtcustom.Rows.Count; a++) { string ShiftName = dtcustom.Rows[a]["CustomShiftName"].ToString(); string StartTime = dtcustom.Rows[a]["StartTime"].ToString(); string EndTime = dtcustom.Rows[a]["EndTime"].ToString(); int hour = Convert.ToInt32(dtcustom.Rows[a]["TotalHrs"].ToString()); dt.Rows.Add(1, ShiftName, client.ClientId, StartTime, EndTime, hour); } DAL.SQLHelp.CopyToServer("Tbl_Clients_Custom_Shift", dt); } } SqlParameter IsSuccessful = new SqlParameter("@IsSuccessful", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(IsSuccessful); // 1 is to Approve Designation // 2 is to Reject Designation int i = DAL.SQLHelp.ExecuteNonQuery("Usp_ApproveOrRejectClients", sqlparam); int value = Convert.ToInt32(IsSuccessful.Value.ToString()); return(value); }
//Add State public int AddState(Models.ClientModel clientmodel) { int value = 0; List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@StateName", clientmodel.StateName)); SqlParameter Issuccesfull = new SqlParameter("@StateResult", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(Issuccesfull); int i = DAL.SQLHelp.ExecuteNonQuery("Usp_InsertState", sqlparam); value = Convert.ToInt32(Issuccesfull.Value.ToString()); return(value); }
public int ApproveOrRejectHoliday(Models.ClientModel clientmodel) { List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@PendingHolidayId", clientmodel.PendingClient_HolidayId)); sqlparam.Add(new SqlParameter("@AddedBy", clientmodel.CreatedBy)); sqlparam.Add(new SqlParameter("@Operation", clientmodel.Operation)); SqlParameter IsSuccessful = new SqlParameter("@Result", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(IsSuccessful); // 2 is to Remove Role int i = DAL.SQLHelp.ExecuteNonQuery("Usp_ApproveOrRejectClientsHoliday", sqlparam); int value = Convert.ToInt32(IsSuccessful.Value.ToString()); return(value); }
//Remove Client From ClientMaster public int RemoveClient(Models.ClientModel client) { List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@ClientId", client.ClientId)); sqlparam.Add(new SqlParameter("@AddedBy", client.UpdatedBy)); sqlparam.Add(new SqlParameter("@Operation", 3)); SqlParameter IsSuccessful = new SqlParameter("@IsSuccessful", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(IsSuccessful); // 2 is to Remove Role int i = DAL.SQLHelp.ExecuteNonQuery("Usp_UpdateClient", sqlparam); int value = Convert.ToInt32(IsSuccessful.Value.ToString()); return(value); }
//add Holiday Details public int UpdateHolidayDetails(Models.ClientModel clientmodel, int operation) { List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@Cl_HolidayId", clientmodel.Client_HolidayId)); sqlparam.Add(new SqlParameter("@HolidayName", clientmodel.HolidayName)); sqlparam.Add(new SqlParameter("@HolidayOn", clientmodel.HolidayOn)); sqlparam.Add(new SqlParameter("@ClientId", clientmodel.ClientId)); sqlparam.Add(new SqlParameter("@IsOptional", clientmodel.IsOptional)); sqlparam.Add(new SqlParameter("@AddedBy", clientmodel.AddedBy)); sqlparam.Add(new SqlParameter("@Operation", operation)); SqlParameter ResultOut = new SqlParameter("@Result", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(ResultOut); int i = DAL.SQLHelp.ExecuteNonQuery("Usp_UpdateClientHoliday", sqlparam); int Result = Convert.ToInt32(ResultOut.Value.ToString()); return(Result); }
public static string PushToBrand(Models.ClientModel Info, Classes.Instbtc.Models.TransactionModel Transaction, string PspStatus, object result, string note, string pin, string psp_name) { if (result.ToString() != "Internal Error" || result != null) { decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString()); decimal OriginalBtcExchangeAmount = decimal.Parse(Transaction.Exchange_Amount.ToString()); decimal DepositAmountDeductionFee = 0; decimal BTCExchangeAmountDeductionFee = 0; if (psp_name.ToLower() == "wire transfer") { Transaction.Psp_ID = 1; } #region Get Right Deduction Fee if (Transaction.Psp_ID == 1) { DepositAmountDeductionFee = (OriginalDepositTransactionAmount * Convert.ToDecimal(0.025)); BTCExchangeAmountDeductionFee = (OriginalBtcExchangeAmount * Convert.ToDecimal(0.025)); } else { DepositAmountDeductionFee = (OriginalDepositTransactionAmount * Convert.ToDecimal(0.05)); BTCExchangeAmountDeductionFee = (OriginalBtcExchangeAmount * Convert.ToDecimal(0.05)); } #endregion decimal FinalDepositAmountToSend = (OriginalDepositTransactionAmount - DepositAmountDeductionFee); decimal FinalBTCAmountToSend = (OriginalBtcExchangeAmount - BTCExchangeAmountDeductionFee); #region If not Approved Send Api Request to Brand to record tx if (PspStatus.ToLower() != "approved") { var s = BrandMakeDeposit(Info.Referral, Info.Email, PspStatus, FinalDepositAmountToSend.ToString(), Transaction.Deposit_Currency, Transaction.PaymentReference, Transaction.CardHolderName, Transaction.CardLast4, "", note, pin, DepositAmountDeductionFee, psp_name); } #endregion #region If Approved Continue the Process if (PspStatus.ToLower() == "approved") { string btcReff = ""; #region Make the BTC transfer var res = Classes.btcWallet.Utilitties.createSelfTransaction(double.Parse(FinalBTCAmountToSend.ToString()), "http://54.200.165.82:4000/"); #region Funds were transfered if (res.error == null) { btcReff = res.txResponse.hash; } #endregion #region No funds else if (res.error != null) { Email.SendNoFundsNotification(Transaction.Client_ID.ToString(), res.error.message); } #endregion #region if tx unconfirmed error persist if (res.error != null) { if (res.error.message.ToLower() == "tx exceeds maximum unconfirmed ancestors.") { #region do ZAP call JavaScriptSerializer ser = new JavaScriptSerializer(); var client = new RestClient("http://54.200.165.82:4000/zap"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/x-www-form-urlencoded"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11; IRestResponse response = client.Execute(request); var dss = ser.Deserialize <dynamic>(response.Content.ToString()); if (dss != null) { var s = dss.TryGetValue("success", out dynamic sc) ? sc : null; if ((bool)s) { res = Classes.btcWallet.Utilitties.createSelfTransaction(double.Parse(FinalBTCAmountToSend.ToString()), "http://54.200.165.82:4000/"); if (res.error == null) { btcReff = res.txResponse.hash; } } else { btcReff = res.txResponse.hash = "N/A"; } } #endregion } } #endregion #endregion if (Transaction.Psp_ID != 1) { EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), FinalDepositAmountToSend.ToString(), FinalBTCAmountToSend.ToString(), Transaction); } #region Create Withdrawal Object WithdrawalModel.MWithdrawal WithdrawalModel = new WithdrawalModel.MWithdrawal { UserId = Info.Id, WalletId = "Not Applicable", ClientName = string.Concat(Info.First_name, " ", Info.Last_name), DocumentId = "Not Applicable", DocuLink = "Not Applicable", Amount = Transaction.Exchange_Amount, Status = "Initial", DocumentStatus = CRM.Models.WithdrawalModel.DocumentStatus.OUT_FOR_SIGNATURE, CreatedDate = DateTime.UtcNow, UsdConversion = 0, ServiceFeeUsd = 0, ServiceFee = BTCExchangeAmountDeductionFee, refference_hash = btcReff, transaction_currency = "BTC" }; #endregion #region Create Initial Wd Request var wd_id = CreateWdRequestReturningId(WithdrawalModel); #endregion if (!string.IsNullOrEmpty(wd_id.ToString())) { using (var conn = Classes.DB.InstBTCDB("instbtc")) { bool updateResult = UpdateCreditedStatus(conn, wd_id.ToString(), PspStatus); if (updateResult) { UpdateUsdValueAmount(conn, wd_id.ToString()); var withdrawalData = GetWithdrawal(conn, wd_id.ToString()); if (withdrawalData.TransactionId == -1 && withdrawalData.Status == "Approved") { var wd_result = InsertTransaction(conn, wd_id.ToString()); if (wd_result.ToString() != "Internal Error" && !string.IsNullOrEmpty(wd_result.ToString())) { var updateWithdrawalTransaction = UpdateTransactionId(conn, wd_id.ToString(), Convert.ToInt32(wd_result)); if (updateWithdrawalTransaction) { var brand_deposit_res = BrandMakeDeposit(Info.Referral, Info.Email, PspStatus, FinalDepositAmountToSend.ToString(), Transaction.Deposit_Currency, Transaction.PaymentReference, Transaction.CardHolderName, Transaction.CardLast4, "", string.Concat("[Refference:", btcReff, "] [Service Fee: ", DepositAmountDeductionFee, "] ", note), pin, DepositAmountDeductionFee, psp_name); } else { //logs issues } } } } } } } #endregion } return("Success"); }
//Add Client Details public int AddClient(Models.ClientModel clientmodel) { Int32 MasterClientID = 0; int value = 0; List <SqlParameter> sqlparam = new List <SqlParameter>(); sqlparam.Add(new SqlParameter("@ClientId", clientmodel.ClientId)); sqlparam.Add(new SqlParameter("@ClientName", clientmodel.ClientName)); sqlparam.Add(new SqlParameter("@StateId", clientmodel.StateId)); sqlparam.Add(new SqlParameter("@CityId", clientmodel.CityId)); sqlparam.Add(new SqlParameter("@ClientAddress", clientmodel.ClientAddress)); sqlparam.Add(new SqlParameter("@PinCode", clientmodel.pinCode)); sqlparam.Add(new SqlParameter("@WebSite", clientmodel.WebSite)); sqlparam.Add(new SqlParameter("@ContactNo", clientmodel.ContactNo)); sqlparam.Add(new SqlParameter("@IP_Address", clientmodel.IP_Address)); sqlparam.Add(new SqlParameter("@Is_Sat_Working", clientmodel.Is_Sat_Working)); sqlparam.Add(new SqlParameter("@AddedBy", clientmodel.AddedBy)); sqlparam.Add(new SqlParameter("@GeneralShift_1", clientmodel.General_Shift1)); sqlparam.Add(new SqlParameter("@GeneralShift_2", clientmodel.General_Shift2)); sqlparam.Add(new SqlParameter("@GeneralShift_3", clientmodel.General_Shift3)); sqlparam.Add(new SqlParameter("@FirstShift", clientmodel.FirstShift)); sqlparam.Add(new SqlParameter("@SecondShift", clientmodel.SecondShift)); sqlparam.Add(new SqlParameter("@NightShift", clientmodel.NightShift)); sqlparam.Add(new SqlParameter("@IsCustomShift", clientmodel.IsCustomShift)); sqlparam.Add(new SqlParameter("@FlexibleTime", clientmodel.FlexibleTime)); sqlparam.Add(new SqlParameter("@NoOfOptionalHoliday", clientmodel.optionalholiday)); sqlparam.Add(new SqlParameter("@Operation", clientmodel.Operation)); //if (clientmodel.Is_Sat_Working == true) //{ sqlparam.Add(new SqlParameter("@IsSat_1", clientmodel.sat1)); sqlparam.Add(new SqlParameter("@IsSat_2", clientmodel.sat2)); sqlparam.Add(new SqlParameter("@IsSat_3", clientmodel.sat3)); sqlparam.Add(new SqlParameter("@IsSat_4", clientmodel.sat4)); sqlparam.Add(new SqlParameter("@IsSat_5", clientmodel.sat5)); SqlParameter MasterClientId = new SqlParameter("@ReturnClientId", SqlDbType.Int) { Direction = ParameterDirection.Output }; SqlParameter succesful = new SqlParameter("@IsSuccessful", SqlDbType.Int) { Direction = ParameterDirection.Output }; sqlparam.Add(MasterClientId); // sqlparam.Add(TempClientId); sqlparam.Add(succesful); int i = DAL.SQLHelp.ExecuteNonQuery("Usp_UpdateClient", sqlparam); value = Convert.ToInt32(succesful.Value.ToString()); if (i != -1 && i != 2) { MasterClientID = Convert.ToInt32(MasterClientId.Value.ToString()); } //Int32 TempClientID = Convert.ToInt32(TempClientId.Value.ToString()); bool isApproveAccess = CheckAccess(clientmodel.AddedBy); return(value); }