Click here to Skip to main content
15,898,538 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
KK Kod27-Mar-15 5:25
KK Kod27-Mar-15 5:25 
AnswerRe: Enumeration in C#,Different Input returning Same enumeration Pin
Eddy Vluggen27-Mar-15 5:22
professionalEddy Vluggen27-Mar-15 5:22 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
KK Kod27-Mar-15 5:26
KK Kod27-Mar-15 5:26 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
Eddy Vluggen27-Mar-15 6:20
professionalEddy Vluggen27-Mar-15 6:20 
AnswerRe: Enumeration in C#,Different Input returning Same enumeration Pin
PIEBALDconsult27-Mar-15 15:52
mvePIEBALDconsult27-Mar-15 15:52 
QuestionImage segmentation - show or hide clusters Pin
Member 1133638227-Mar-15 4:15
Member 1133638227-Mar-15 4:15 
AnswerRe: Image segmentation - show or hide clusters Pin
Eddy Vluggen27-Mar-15 9:29
professionalEddy Vluggen27-Mar-15 9:29 
QuestionI found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 15:35
patrickjiang258026-Mar-15 15:35 
I get some source codes from a textbook and rewrite them making a small system. It can CRUD user. Now I find it low efficency for coding. For example, UserDAL contains a lot of SQL scripts and they are easy to make error. UserBLL is too simple. I do not know how to improve coding efficiency. Could you give me any advices ?

The following is UserDAL source code, I intend to post UserBLL and UserModel source code but code-project remind me too long:

C#
public class UserDAL
    {
        SQLHelper db = new SQLHelper();
        
        /// <summary>
        /// Read All User Object
        /// </summary>
        /// <returns></returns>
        public DataTable SelectAllUser()
        {
            string sql = @"SELECT [UserID],[Password],[Name],[Sex],[Phone]," +
                "[Tutor],[DptName],[College],[University]," +
                "[Major],[EnrollYear],[Cntnt] " +
                "FROM [TrainingExam].[dbo].[ExprmntUser]"; 
            return db.GetDataTable(sql);
        }
        /// <summary>
        /// Insert User into DataBase
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public int InsertUser(UserModel user)
        {
            string sql = @"INSERT INTO [TrainingExam].[dbo].[ExprmntUser] VALUES(" +
                "@UserID, @Pass, @Name, @Sex, @Phone, @Tutor, @DptName, @College, @University, @Major, @EnrollYear, @Content)";
            SqlParameter[] parameters = 
            {
                new SqlParameter("@UserID", user.UserID),
                new SqlParameter("@Pass", user.Pass),
                new SqlParameter("@Name", user.Name),
                new SqlParameter("@Sex", user.Sex),
                new SqlParameter("@Phone", user.Phone),
                new SqlParameter("@Tutor", user.Tutor),
                new SqlParameter("@DptName", user.DptName),
                new SqlParameter("@College", user.College),
                new SqlParameter("@University", user.University),
                new SqlParameter("@Major", user.Major),
                new SqlParameter("@EnrollYear", user.EnrollYear),
                new SqlParameter("@Content", user.Content)
            };
            return db.ExecuteNonQuery(sql, parameters);
        }
        /// <summary>
        /// Delete User Object
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public int DeleteUser(UserModel user)
        {
            string sql = @"DELETE FROM [TrainingExam].[dbo].[ExprmntUser] WHERE UserID=@UserID";
            SqlParameter parameter = new SqlParameter("@UserID", user.UserID);
            return db.ExecuteNonQuery(sql, parameter);
        }
        /// <summary>
        /// Update User Object
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public int UpdateUser(UserModel user)
        {
            string sql = @"UPDATE [TrainingExam].[dbo].[ExprmntUser] SET UserID=@UserID, Name=@Name, Sex=@Sex, Phone=@Phone, EnrollYear=@EnrollYear, " +
                "Tutor=@Tutor, Major=@Major, DptName=@DptName, College=@College, University=@University, Content=@Content " +
                "WHERE UserID=@UserID";
            SqlParameter[] parameters = 
            {
                new SqlParameter("@UserID", user.UserID),
                new SqlParameter("@Name", user.Name),
                new SqlParameter("@Sex", user.Sex),
                new SqlParameter("@Phone", user.Phone),
                new SqlParameter("@EnrollYear", user.EnrollYear),

                new SqlParameter("@Tutor", user.Tutor),
                new SqlParameter("@Major", user.Major),
                new SqlParameter("@DptName", user.DptName),
                new SqlParameter("@College", user.College),
                new SqlParameter("@University", user.University),
                new SqlParameter("@Content", user.Content),
                new SqlParameter("@UserID", user.UserID)
            };
            return db.ExecuteNonQuery(sql, parameters);
        }
    }

AnswerRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Afzaal Ahmad Zeeshan26-Mar-15 17:01
professionalAfzaal Ahmad Zeeshan26-Mar-15 17:01 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 22:27
patrickjiang258026-Mar-15 22:27 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Afzaal Ahmad Zeeshan26-Mar-15 22:39
professionalAfzaal Ahmad Zeeshan26-Mar-15 22:39 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 22:49
patrickjiang258026-Mar-15 22:49 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Afzaal Ahmad Zeeshan26-Mar-15 22:51
professionalAfzaal Ahmad Zeeshan26-Mar-15 22:51 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 22:58
patrickjiang258026-Mar-15 22:58 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
F-ES Sitecore27-Mar-15 0:41
professionalF-ES Sitecore27-Mar-15 0:41 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258027-Mar-15 4:37
patrickjiang258027-Mar-15 4:37 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
F-ES Sitecore27-Mar-15 4:54
professionalF-ES Sitecore27-Mar-15 4:54 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258027-Mar-15 5:02
patrickjiang258027-Mar-15 5:02 
SuggestionRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Richard Deeming27-Mar-15 2:34
mveRichard Deeming27-Mar-15 2:34 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258027-Mar-15 4:44
patrickjiang258027-Mar-15 4:44 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258027-Mar-15 4:50
patrickjiang258027-Mar-15 4:50 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Richard Deeming27-Mar-15 4:59
mveRichard Deeming27-Mar-15 4:59 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258027-Mar-15 5:20
patrickjiang258027-Mar-15 5:20 
QuestionThe usage of Unsigned types Pin
GerVenson26-Mar-15 5:36
professionalGerVenson26-Mar-15 5:36 
GeneralRe: The usage of Unsigned types Pin
PIEBALDconsult26-Mar-15 5:52
mvePIEBALDconsult26-Mar-15 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.