public DataResultArgs <string> Set_Payment(PaymentEntity entity) { try { DataProcess.ControlAdminAuthorization(true); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@DatabaseProcess", entity.DatabaseProcess); cmd.Parameters.AddWithValue("@id", entity.Id); cmd.Parameters.AddWithValue("@studentId", entity.StudentId); cmd.Parameters.AddWithValue("@year", entity.Year); cmd.Parameters.AddWithValue("@month", entity.Month); cmd.Parameters.AddWithValue("@amount", entity.Amount); cmd.Parameters.AddWithValue("@isPayment", entity.IsPayment); cmd.Parameters.AddWithValue("@paymentDate", entity.PaymentDate); cmd.Parameters.AddWithValue("@paymentType", entity.PaymentType); cmd.Parameters.AddWithValue("@isActive", entity.IsActive); cmd.Parameters.AddWithValue("@isNotPayable", entity.IsNotPayable); cmd.Parameters.AddWithValue("@isChangeAmountPaymentNotOK", entity.IsChangeAmountPaymentNotOK); using (SqlConnection con = Connection.Conn) { con.Open(); DataResultArgs <string> resultSet = DataProcess.ExecuteProcString(con, cmd, "set_Payment"); con.Close(); return(resultSet); } } catch (Exception e) { DataResultArgs <string> result = new DataResultArgs <string>(); result.HasError = true; result.ErrorDescription = e.Message; return(result); } }
public DataResultArgs <StudentEntity> Set_Student(StudentEntity entity) { try { DataProcess.ControlAdminAuthorization(true); if (entity.Id > 0 && entity.DatabaseProcess == DatabaseProcess.Add) { entity.DatabaseProcess = DatabaseProcess.Update; } DataResultArgs <StudentEntity> resultSet = new DataResultArgs <StudentEntity>(); resultSet.Result = entity; SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@DatabaseProcess", entity.DatabaseProcess); cmd.Parameters.AddWithValue("@id", entity.Id); cmd.Parameters.AddWithValue("@citizenshipNumber", entity.CitizenshipNumber); cmd.Parameters.AddWithValue("@name", entity.Name); cmd.Parameters.AddWithValue("@surname", entity.Surname); cmd.Parameters.AddWithValue("@middleName", entity.MiddleName); cmd.Parameters.AddWithValue("@fatherName", entity.FatherName); cmd.Parameters.AddWithValue("@motherName", entity.MotherName); cmd.Parameters.AddWithValue("@birthday", entity.Birthday); cmd.Parameters.AddWithValue("@fatherPhoneNumber", entity.FatherPhoneNumber); cmd.Parameters.AddWithValue("@motherPhoneNumber", entity.MotherPhoneNumber); cmd.Parameters.AddWithValue("@isActive", entity.IsActive); cmd.Parameters.AddWithValue("@isStudent", entity.IsStudent); cmd.Parameters.AddWithValue("@notes", entity.Notes); cmd.Parameters.AddWithValue("@dateOfMeeting", entity.DateOfMeeting); cmd.Parameters.AddWithValue("@spokenPrice", entity.SpokenPrice); cmd.Parameters.AddWithValue("@email", entity.Email); using (SqlConnection con = Connection.Conn) { con.Open(); DataResultArgs <string> currentResultSet = DataProcess.ExecuteProcString(con, cmd, "set_Student"); con.Close(); resultSet.HasError = currentResultSet.HasError; resultSet.ErrorDescription = currentResultSet.ErrorDescription; resultSet.MyException = currentResultSet.MyException; if (entity.DatabaseProcess == DatabaseProcess.Add && !currentResultSet.HasError) { resultSet.Result.Id = GeneralFunctions.GetData <Int32>(currentResultSet.Result); entity.Id = GeneralFunctions.GetData <Int32>(currentResultSet.Result); } } if (entity.IsAddAfterPaymentUnPayment) { List <PaymentTypeEntity> paymentTypeList = new PaymentTypeBusiness().Get_PaymentType(); foreach (PaymentTypeEntity paymentTypeEntity in paymentTypeList) { for (int i = 1; i < DateTime.Today.Month; i++) { PaymentEntity paymentEntity = new PaymentEntity(); paymentEntity.Id = 0; paymentEntity.DatabaseProcess = DatabaseProcess.Add; paymentEntity.Year = (short)DateTime.Today.Year; paymentEntity.StudentId = entity.Id; paymentEntity.IsNotPayable = true; paymentEntity.IsActive = true; paymentEntity.IsDeleted = false; paymentEntity.Month = (short)i; paymentEntity.IsPayment = false; paymentEntity.Amount = ((PaymentTypeEnum)paymentTypeEntity.Id == PaymentTypeEnum.Okul && entity.SpokenPrice.HasValue && entity.SpokenPrice.Value > 0) ? entity.SpokenPrice.Value : paymentTypeEntity.Amount; paymentEntity.PaymentType = paymentTypeEntity.Id; paymentEntity.AddedOn = DateTime.Now; new PaymentBusiness().Set_Payment(paymentEntity); } } } AllStudentWithCache = null; Get_AllStudentWithCache(); return(resultSet); } catch (Exception e) { DataResultArgs <StudentEntity> result = new DataResultArgs <StudentEntity>(); result.HasError = true; result.ErrorDescription = e.Message; return(result); } }