Esempio n. 1
0
        private void processToDatabase(DatabaseProcess databaseProcess)
        {
            StudentEntity entity = new StudentEntity();

            entity.DatabaseProcess = databaseProcess;
            entity.Id = GeneralFunctions.GetData <Int32>(hdnId.Value);
            entity.CitizenshipNumber = txtTckn.Text;
            entity.Name       = txtName.Text;
            entity.Surname    = txtSurname.Text;
            entity.MiddleName = txtMiddleName.Text;
            entity.FatherName = txtFatherName.Text;
            entity.MotherName = txtMotherName.Text;

            if (!string.IsNullOrEmpty(txtBirthday.Text))
            {
                entity.Birthday = GeneralFunctions.GetData <DateTime>(txtBirthday.Text);
            }
            entity.FatherPhoneNumber = txtFatherPhoneNumber.Text;
            entity.MotherPhoneNumber = txtMotherPhoneNumber.Text;
            entity.IsActive          = chcIsActive.Checked;
            entity.IsStudent         = drpStudentState.SelectedValue == "0";
            entity.Notes             = txtNotes.Text;
            entity.DateOfMeeting     = GeneralFunctions.GetData <DateTime>(txtDateOfMeeting.Text);
            entity.SpokenPrice       = GeneralFunctions.GetData <decimal>(txtSpokenPrice.Text);
            entity.Email             = txtEmail.Text;


            if (entity.DatabaseProcess == DatabaseProcess.Add)
            {
                entity.IsAddAfterPaymentUnPayment = true;
            }

            if (hdnStudentState.Value == "1" && entity.IsStudent)
            {
                entity.IsAddAfterPaymentUnPayment = true;
            }

            DataResultArgs <StudentEntity> resultSet = business.Set_Student(entity);

            if (resultSet.HasError)
            {
                divInformation.ErrorText = resultSet.ErrorDescription;
                return;
            }
            else
            {
                if (databaseProcess == DatabaseProcess.Deleted)
                {
                    divInformation.SuccessfulText = RecordMessage.Delete;
                    pnlBody.Enabled = false;
                }
                else
                {
                    divInformation.SuccessfulText = (databaseProcess == DatabaseProcess.Add) ? RecordMessage.Add : RecordMessage.Update;
                    btnSubmit.Text  = ButtonText.Submit;
                    pnlBody.Enabled = false;

                    if (entity.IsStudent)
                    {
                        divInformation.SetAnotherText("<a href = \"PaymentDetail.aspx?Id=" + resultSet.Result.EncryptId + "\">" + paymentDetail + "</a>");
                    }
                    else
                    {
                        btnPaymentDetail.Visible = false;
                    }
                }
            }
        }