Пример #1
0
        public DataResultArgs <List <PaymentEntity> > Get_Payment(int studentId, string year)
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <List <PaymentEntity> > resultSet = new DataResultArgs <List <PaymentEntity> >();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@studentId", studentId);
            cmd.Parameters.AddWithValue("@year", year);
            using (SqlConnection con = Connection.Conn)
            {
                con.Open();
                DataResultArgs <SqlDataReader> result = DataProcess.ExecuteProcDataReader(con, cmd, "get_Payment");
                if (result.HasError)
                {
                    resultSet.HasError         = result.HasError;
                    resultSet.ErrorDescription = result.ErrorDescription;
                    resultSet.ErrorCode        = result.ErrorCode;
                }
                else
                {
                    List <PaymentEntity> lst = GetList(result);
                    resultSet.Result = lst;
                }

                con.Close();
            }

            return(resultSet);
        }
        public DataResultArgs <bool> Set_Admin(AdminEntity 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("@userName", entity.UserName);
                cmd.Parameters.AddWithValue("@password", entity.Password);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                cmd.Parameters.AddWithValue("@LastLoginDate", entity.LastLoginDate);
                cmd.Parameters.AddWithValue("@AdminType", entity.AdminType);

                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <bool> resultSet = DataProcess.ExecuteProc(con, cmd, "set_Admin");
                    con.Close();
                    return(resultSet);
                }
            }
            catch (Exception e)
            {
                DataResultArgs <bool> result = new DataResultArgs <bool>();
                result.HasError         = true;
                result.ErrorDescription = e.Message;
                return(result);
            }
        }
Пример #3
0
        public DataResultArgs <List <PaymentEntity> > Get_PaymentForCurrentMonth()
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <List <PaymentEntity> > resultSet = new DataResultArgs <List <PaymentEntity> >();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;

            using (SqlConnection con = Connection.Conn)
            {
                con.Open();
                DataResultArgs <SqlDataReader> result =
                    DataProcess.ExecuteProcDataReader(con, cmd, "Get_PaymentForCurrentMonth");
                if (result.HasError)
                {
                    resultSet.HasError         = result.HasError;
                    resultSet.ErrorDescription = result.ErrorDescription;
                    resultSet.ErrorCode        = result.ErrorCode;
                }
                else
                {
                    List <PaymentEntity> lst = GetList(result);
                    resultSet.Result = lst;
                }

                con.Close();
            }

            return(resultSet);
        }
Пример #4
0
        private static List <PaymentEntity> GetList(DataResultArgs <SqlDataReader> result)
        {
            DataProcess.ControlAdminAuthorization();

            SqlDataReader        dr  = result.Result;
            List <PaymentEntity> lst = new List <PaymentEntity>();

            while (dr.Read())
            {
                var paymentEntity = new PaymentEntity
                {
                    Id           = GeneralFunctions.GetData <Int32>(dr["id"]),
                    StudentId    = GeneralFunctions.GetData <Int32?>(dr["studentId"]),
                    Year         = GeneralFunctions.GetData <Int16?>(dr["year"]),
                    Month        = GeneralFunctions.GetData <Int16?>(dr["month"]),
                    Amount       = GeneralFunctions.GetData <Decimal?>(dr["amount"]),
                    IsPayment    = GeneralFunctions.GetData <Boolean?>(dr["isPayment"]),
                    PaymentDate  = GeneralFunctions.GetData <DateTime?>(dr["paymentDate"]),
                    PaymentType  = GeneralFunctions.GetData <Int32?>(dr["paymentType"]),
                    IsActive     = GeneralFunctions.GetData <Boolean?>(dr["isActive"]),
                    IsNotPayable = GeneralFunctions.GetData <Boolean>(dr["isNotPayable"])
                };
                lst.Add(paymentEntity);
            }

            dr.Close();
            return(lst);
        }
Пример #5
0
        public DataResultArgs <bool> Set_PaymentType(PaymentTypeEntity 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("@name", entity.Name);
                cmd.Parameters.AddWithValue("@amount", entity.Amount);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <bool> resultSet = DataProcess.ExecuteProc(con, cmd, "set_PaymentType");
                    con.Close();
                    staticPaymentTypeList = null;
                    return(resultSet);
                }
            }
            catch (Exception ex)
            {
                DataResultArgs <bool> result = new DataResultArgs <bool>();
                result.HasError         = true;
                result.ErrorDescription = ex.Message;
                return(result);
            }
        }
Пример #6
0
        public DataResultArgs <List <PaymentTypeEntity> > Get_PaymentType(SearchEntity entity)
        {
            DataProcess.ControlAdminAuthorization();

            if (staticPaymentTypeList == null)
            {
                DataResultArgs <List <PaymentTypeEntity> > resultSet = new DataResultArgs <List <PaymentTypeEntity> >();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@id", entity.Id);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                cmd.Parameters.AddWithValue("@isDeleted", entity.IsDeleted);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <SqlDataReader> result =
                        DataProcess.ExecuteProcDataReader(con, cmd, "get_PaymentType");
                    if (result.HasError)
                    {
                        resultSet.HasError         = result.HasError;
                        resultSet.ErrorDescription = result.ErrorDescription;
                        resultSet.ErrorCode        = result.ErrorCode;
                    }
                    else
                    {
                        SqlDataReader            dr  = result.Result;
                        List <PaymentTypeEntity> lst = new List <PaymentTypeEntity>();
                        PaymentTypeEntity        elist;
                        while (dr.Read())
                        {
                            elist           = new PaymentTypeEntity();
                            elist.Id        = GeneralFunctions.GetData <Int32>(dr["id"]);
                            elist.Name      = GeneralFunctions.GetData <String>(dr["name"]);
                            elist.Amount    = GeneralFunctions.GetData <Decimal?>(dr["amount"]);
                            elist.IsActive  = GeneralFunctions.GetData <Boolean?>(dr["isActive"]);
                            elist.UpdatedOn = GeneralFunctions.GetData <DateTime>(dr["updatedOn"]);
                            lst.Add(elist);
                        }


                        dr.Close();

                        resultSet.Result = lst;
                    }
                    con.Close();
                }

                staticPaymentTypeList = resultSet;
            }

            return(staticPaymentTypeList);
        }
Пример #7
0
        public DataResultArgs <PaymentTypeEntity> Get_PaymentTypeWithId(int id)
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <List <PaymentTypeEntity> > resultSet = Get_PaymentType(new SearchEntity()
            {
                IsActive = true, IsDeleted = false
            });

            DataResultArgs <PaymentTypeEntity> result = new DataResultArgs <PaymentTypeEntity>();

            EntityHelper.CopyDataResultArgs <PaymentTypeEntity>(resultSet, result);

            result.Result = resultSet.Result.FirstOrDefault(o => o.Id == id);

            return(result);
        }
        public DataResultArgs <List <StudentEntity> > Get_Student(SearchEntity entity)
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <List <StudentEntity> > resultSet = new DataResultArgs <List <StudentEntity> >();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@id", entity.Id);
            cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
            cmd.Parameters.AddWithValue("@isDeleted", entity.IsDeleted);
            using (SqlConnection con = Connection.Conn)
            {
                con.Open();
                DataResultArgs <SqlDataReader> result = DataProcess.ExecuteProcDataReader(con, cmd, "get_Student");
                if (result.HasError)
                {
                    resultSet.HasError         = result.HasError;
                    resultSet.ErrorDescription = result.ErrorDescription;
                    resultSet.ErrorCode        = result.ErrorCode;
                }
                else
                {
                    SqlDataReader        dr  = result.Result;
                    List <StudentEntity> lst = new List <StudentEntity>();
                    while (dr.Read())
                    {
                        var studentEntity = GetEntity(dr);
                        lst.Add(studentEntity);
                    }

                    dr.Close();
                    resultSet.Result = lst;
                }
                con.Close();
            }

            return(resultSet);
        }
        public StudentEntity Get_StudentWithPaymentList(int id)
        {
            DataProcess.ControlAdminAuthorization();

            StudentEntity entity = Get_Student(new SearchEntity()
            {
                Id = id
            }).Result[0];

            DataResultArgs <List <PaymentEntity> > paymentListResult =
                new PaymentBusiness().Get_Payment(entity.Id, DateTime.Today.Year.ToString());

            if (!paymentListResult.HasError)
            {
                if (paymentListResult.Result.Any())
                {
                    entity.PaymentList = paymentListResult.Result;
                }
            }

            return(entity);
        }
        public DataResultArgs <StudentEntity> Get_Student(string citizenshipNumber)
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <StudentEntity> resultSet = new DataResultArgs <StudentEntity>();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@citizenshipNumber", citizenshipNumber);

            using (SqlConnection con = Connection.Conn)
            {
                con.Open();
                DataResultArgs <SqlDataReader> result = DataProcess.ExecuteProcDataReader(con, cmd, "get_Student");
                if (result.HasError)
                {
                    resultSet.HasError         = result.HasError;
                    resultSet.ErrorDescription = result.ErrorDescription;
                    resultSet.ErrorCode        = result.ErrorCode;
                }
                else
                {
                    SqlDataReader dr = result.Result;
                    StudentEntity elist;
                    while (dr.Read())
                    {
                        elist            = GetEntity(dr);
                        resultSet.Result = elist;
                    }

                    dr.Close();
                }
                con.Close();
            }

            return(resultSet);
        }
Пример #11
0
        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);
            }
        }
        private static StudentEntity GetEntity(SqlDataReader dr)
        {
            DataProcess.ControlAdminAuthorization();

            StudentEntity elist = new StudentEntity();

            elist.Id = GeneralFunctions.GetData <Int32>(dr["id"]);
            elist.CitizenshipNumber = GeneralFunctions.GetData <String>(dr["citizenshipNumber"]);
            elist.Name              = GeneralFunctions.GetData <String>(dr["name"]);
            elist.Surname           = GeneralFunctions.GetData <String>(dr["surname"]);
            elist.MiddleName        = GeneralFunctions.GetData <String>(dr["middleName"]);
            elist.FatherName        = GeneralFunctions.GetData <String>(dr["fatherName"]);
            elist.MotherName        = GeneralFunctions.GetData <String>(dr["motherName"]);
            elist.Birthday          = GeneralFunctions.GetData <DateTime?>(dr["birthday"]);
            elist.FatherPhoneNumber = GeneralFunctions.GetData <String>(dr["fatherPhoneNumber"]);
            elist.MotherPhoneNumber = GeneralFunctions.GetData <String>(dr["motherPhoneNumber"]);
            elist.IsActive          = GeneralFunctions.GetData <Boolean>(dr["isActive"]);
            elist.IsStudent         = GeneralFunctions.GetData <Boolean>(dr["isStudent"]);
            elist.Notes             = GeneralFunctions.GetData <String>(dr["notes"]);
            elist.DateOfMeeting     = GeneralFunctions.GetData <DateTime?>(dr["dateOfMeeting"]);
            elist.SpokenPrice       = GeneralFunctions.GetData <Decimal?>(dr["spokenPrice"]);
            elist.Email             = GeneralFunctions.GetData <String>(dr["email"]);
            return(elist);
        }
        public DataResultArgs <StudentEntity> Get_Student(int studentId)
        {
            DataProcess.ControlAdminAuthorization();

            DataResultArgs <StudentEntity> resultSet = new DataResultArgs <StudentEntity>();

            DataResultArgs <List <StudentEntity> > studentList = Get_Student(new SearchEntity()
            {
                Id = studentId
            });

            if (studentList.HasError)
            {
                resultSet.HasError         = studentList.HasError;
                resultSet.ErrorDescription = studentList.ErrorDescription;
                resultSet.MyException      = studentList.MyException;
            }
            else
            {
                resultSet.Result = studentList.Result.FirstOrDefault();
            }

            return(resultSet);
        }
        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);
            }
        }