public void InsertMembersInfo(MembersInfo membersInfo)
        {
            string query = @"insert into MembersInfo(MCnic , MName , MAddress , MPhone ) values(@MCnic , @MName , @MAddress , @MPhone)";

            SqlCommand sqlCommand = new SqlCommand(query, GetConnToLocalDb());

            SqlParameter sqlParameter = new SqlParameter
            {
                ParameterName = "MCnic",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MCnic
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MName",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MName
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MAddress",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MAddress
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MPhone",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MPhone
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlCommand.ExecuteNonQuery();
        }
        public MembersInfo GetMembersInfo(string MPhone, string MName)
        {
            SQLConn sQLConn = new SQLConn();

            string query = @"select * from membersinfo where MPhone = @MPhone and MName = @MName";

            SqlCommand sqlCommand = new SqlCommand(query, sQLConn.GetConnToLocalDb());

            SqlParameter sqlParameter = new SqlParameter
            {
                ParameterName = "MPhone",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = MPhone
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MName",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = MName
            };

            sqlCommand.Parameters.Add(sqlParameter);

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            if (sqlDataReader.Read())
            {
                MembersInfo membersInfo = new MembersInfo
                {
                    MCnic    = sqlDataReader[0].ToString(),
                    MName    = sqlDataReader[1].ToString(),
                    MAddress = sqlDataReader[2].ToString(),
                    MPhone   = sqlDataReader[3].ToString()
                };
                return(membersInfo);
            }
            return(null);
        }
        public void UpdateMembersInfo(MembersInfo membersInfo, string CName, string CPhone)
        {
            string query = @"update MembersInfo set MCnic=@MCnic , MName=@MName , MAddress=@MAddress , MPhone=@MPhone Where MPhone = @CPhone and MName = @CName";

            SqlCommand sqlCommand = new SqlCommand(query, GetConnToLocalDb());

            SqlParameter sqlParameter = new SqlParameter
            {
                ParameterName = "CPhone",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = CPhone
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "CName",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = CName
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MCnic",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MCnic
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MName",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MName
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MAddress",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MAddress
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "MPhone",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = membersInfo.MPhone
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlCommand.ExecuteNonQuery();
        }