Esempio n. 1
0
        public ReturnFPBCheckingDetail SelectByFPBCheckingID(int FPBCheckingID)
        {
            List <FPBCheckingDetail> lstFPBCheckingDetail    = null;
            FPBCheckingDetail        FPBCheckingDetail       = null;
            ReturnFPBCheckingDetail  returnFPBCheckingDetail = new ReturnFPBCheckingDetail();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_FPBCheckingDetail_SelectByFPBCheckingID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@FPBCheckingID", SqlDbType.Int)).Value = FPBCheckingID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstFPBCheckingDetail = new List <FPBCheckingDetail>();
                                while (sqlDr.Read())
                                {
                                    FPBCheckingDetail               = new FPBCheckingDetail();
                                    FPBCheckingDetail.ID            = int.Parse(sqlDr["ID"].ToString());
                                    FPBCheckingDetail.FPBCheckingID = int.Parse(sqlDr["FPBCheckingID"].ToString());
                                    FPBCheckingDetail.Images        = sqlDr["Images"].ToString();
                                    //FPBCheckingDetail.FPBCheckingItemID = int.Parse(sqlDr["FPBCheckingItemID"].ToString());
                                    FPBCheckingDetail.Result        = sqlDr["Result"].ToString();
                                    FPBCheckingDetail.ResultContent = sqlDr["ResultContent"].ToString();
                                    //FPBCheckingDetail.CheckingItemName = sqlDr["CheckingItemName"].ToString();
                                    //FPBCheckingDetail.FrequencyID = int.Parse(sqlDr["FrequencyID"].ToString());
                                    lstFPBCheckingDetail.Add(FPBCheckingDetail);
                                }
                                returnFPBCheckingDetail.Code    = "00";
                                returnFPBCheckingDetail.Message = "Lấy dữ liệu thành công.";
                                returnFPBCheckingDetail.LstFPBCheckingDetail = lstFPBCheckingDetail;
                            }
                            else
                            {
                                returnFPBCheckingDetail.Code    = "01";
                                returnFPBCheckingDetail.Message = "Không tồn tại bản ghi nào.";
                                returnFPBCheckingDetail.Total   = 0;
                                returnFPBCheckingDetail.LstFPBCheckingDetail = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPBCheckingDetail.Code    = "99";
                returnFPBCheckingDetail.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPBCheckingDetail.Total   = 0;
                returnFPBCheckingDetail.LstFPBCheckingDetail = null;
                mylog4net.Error("SelectByFPBCheckingID", ex);
            }
            return(returnFPBCheckingDetail);
        }
Esempio n. 2
0
        public ReturnProgramName ListAll()
        {
            List <ProgramName> lstProgramName    = null;
            ProgramName        programname       = null;
            ReturnProgramName  returnProgramName = new ReturnProgramName();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProgramName_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProgramName = new List <ProgramName>();
                                while (sqlDr.Read())
                                {
                                    programname              = new ProgramName();
                                    programname.programName  = sqlDr["ProgramName"].ToString();
                                    programname.ProgramType  = sqlDr["ProgramType"].ToString();
                                    programname.FactoryID    = sqlDr["FactoryID"].ToString();
                                    programname.OperatorID   = Int32.Parse(sqlDr["OperatorID"].ToString());
                                    programname.OperatorName = sqlDr["UserName"].ToString();
                                    programname.CreatedDate  = DateTime.Parse(sqlDr["CreatedDate"].ToString());
                                    lstProgramName.Add(programname);
                                }
                                returnProgramName.Code           = "00";
                                returnProgramName.Message        = "Lấy dữ liệu thành công.";
                                returnProgramName.lstProgramName = lstProgramName;
                                returnProgramName.userID         = MyShareInfo.ID;
                                returnProgramName.UserName       = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnProgramName.Code           = "01";
                                returnProgramName.Message        = "Không tồn tại bản ghi nào.";
                                returnProgramName.Total          = 0;
                                returnProgramName.userID         = MyShareInfo.ID;
                                returnProgramName.UserName       = MyShareInfo.UserName;
                                returnProgramName.lstProgramName = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProgramName.Code           = "99";
                returnProgramName.Message        = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProgramName.Total          = 0;
                returnProgramName.lstProgramName = null;
                mylog4net.Error("", ex);
            }
            return(returnProgramName);
        }
Esempio n. 3
0
        public ReturnLine ListAll()
        {
            List <Line> lstLine    = null;
            Line        line       = null;
            ReturnLine  returnLine = new ReturnLine();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tLine_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;


                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstLine = new List <Line>();
                                while (sqlDr.Read())
                                {
                                    line           = new Line();
                                    line.LineID    = sqlDr["LineID"].ToString();
                                    line.LineName  = sqlDr["LineName"].ToString();
                                    line.FactoryID = sqlDr["FactoryID"].ToString();
                                    line.isActive  = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstLine.Add(line);
                                }
                                returnLine.Code     = "00";
                                returnLine.Message  = "Lấy dữ liệu thành công.";
                                returnLine.LstLine  = lstLine;
                                returnLine.UserID   = MyShareInfo.ID;
                                returnLine.UserName = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnLine.Code    = "01";
                                returnLine.Message = "Không tồn tại bản ghi nào.";
                                returnLine.Total   = 0;
                                returnLine.LstLine = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnLine.Code    = "99";
                returnLine.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnLine.Total   = 0;
                returnLine.LstLine = null;
                mylog4net.Error("", ex);
            }
            return(returnLine);
        }
Esempio n. 4
0
        public string getUserNameByID(int UserID)
        {
            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tUser_getUserNameByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.VarChar)).Value = UserID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                while (sqlDr.Read())
                                {
                                    return(sqlDr[0].ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return("");
            }
            return("");
        }
Esempio n. 5
0
        public ReturnUser UserAll()
        {
            List <User> lstUser    = null;
            User        user       = null;
            ReturnUser  returnUser = new ReturnUser();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tUser_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstUser = new List <User>();
                                while (sqlDr.Read())
                                {
                                    user              = new User();
                                    user.ID           = int.Parse(sqlDr["ID"].ToString());
                                    user.FullName     = sqlDr["FullName"].ToString();
                                    user.UserName     = sqlDr["UserName"].ToString();
                                    user.PassWord     = sqlDr["PassWord"].ToString();
                                    user.MobileNumber = sqlDr["MobileNumber"].ToString();
                                    user.FactoryID    = sqlDr["FactoryID"].ToString();
                                    user.isActive     = int.Parse(sqlDr["isActive"].ToString());
                                    //user.RoleID = int.Parse(sqlDr["RoleID"].ToString());
                                    lstUser.Add(user);
                                }
                                returnUser.Code    = "00";
                                returnUser.Message = "Lấy dữ liệu thành công.";
                                returnUser.lstUser = lstUser;
                            }
                            else
                            {
                                returnUser.Code    = "01";
                                returnUser.Message = "Không tồn tại bản ghi nào.";
                                returnUser.Total   = 0;
                                returnUser.lstUser = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnUser.Code    = "99";
                returnUser.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnUser.Total   = 0;
                returnUser.lstUser = null;
                mylog4net.Error("", ex);
            }
            return(returnUser);
        }
        public ReturnFPBCheckingItem GetbyMachineID(string MachineID, int FrequencyID)
        {
            List <FPBCheckingItem> lstFPBCheckingItem    = null;
            FPBCheckingItem        FPBCheckingItem       = null;
            ReturnFPBCheckingItem  returnFPBCheckingItem = new ReturnFPBCheckingItem();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_FPBCheckingItem_SelectByMachineID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.VarChar)).Value = MachineID;
                        cmd.Parameters.Add(new SqlParameter("@FrequencyID", SqlDbType.Int)).Value   = FrequencyID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstFPBCheckingItem = new List <FPBCheckingItem>();
                                while (sqlDr.Read())
                                {
                                    FPBCheckingItem = new FPBCheckingItem();
                                    FPBCheckingItem.IDFPBCheckingItem = int.Parse(sqlDr["IDFPBCheckingItem"].ToString());
                                    FPBCheckingItem.MachineID         = sqlDr["MachineID"].ToString();
                                    FPBCheckingItem.CheckingItemName  = sqlDr["CheckingItemName"].ToString();
                                    FPBCheckingItem.FrequencyID       = int.Parse(sqlDr["FrequencyID"].ToString());
                                    FPBCheckingItem.isActive          = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstFPBCheckingItem.Add(FPBCheckingItem);
                                }
                                returnFPBCheckingItem.Code               = "00";
                                returnFPBCheckingItem.Message            = "Lấy dữ liệu thành công.";
                                returnFPBCheckingItem.LstFPBCheckingItem = lstFPBCheckingItem;
                            }
                            else
                            {
                                returnFPBCheckingItem.Code               = "01";
                                returnFPBCheckingItem.Message            = "Không tồn tại bản ghi nào.";
                                returnFPBCheckingItem.Total              = 0;
                                returnFPBCheckingItem.LstFPBCheckingItem = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPBCheckingItem.Code               = "99";
                returnFPBCheckingItem.Message            = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPBCheckingItem.Total              = 0;
                returnFPBCheckingItem.LstFPBCheckingItem = null;
                mylog4net.Error("", ex);
            }
            return(returnFPBCheckingItem);
        }
Esempio n. 7
0
        public ReturnMenu GetbyID(int ID)
        {
            List <Menu> lstMenu    = null;
            Menu        menu       = null;
            ReturnMenu  returnMenu = new ReturnMenu();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tMenu_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = ID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMenu = new List <Menu>();
                                while (sqlDr.Read())
                                {
                                    menu              = new Menu();
                                    menu.ID           = int.Parse(sqlDr["ID"].ToString());
                                    menu.MenuName     = sqlDr["MenuName"].ToString();
                                    menu.DisplayName  = sqlDr["DisplayName"].ToString();
                                    menu.ParentMenuID = int.Parse(sqlDr["ParentMenuID"].ToString());
                                    menu.isActive     = int.Parse(sqlDr["isActive"].ToString());
                                    menu.UrlLink      = sqlDr["UrlLink"].ToString();

                                    lstMenu.Add(menu);
                                }
                                returnMenu.Code    = "00";
                                returnMenu.Message = "Lấy dữ liệu thành công.";
                                returnMenu.lstMenu = lstMenu;
                            }
                            else
                            {
                                returnMenu.Code    = "01";
                                returnMenu.Message = "Không tồn tại bản ghi nào.";
                                returnMenu.Total   = 0;
                                returnMenu.lstMenu = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMenu.Code    = "99";
                returnMenu.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMenu.Total   = 0;
                returnMenu.lstMenu = null;
                mylog4net.Error("", ex);
            }
            return(returnMenu);
        }
Esempio n. 8
0
        public ReturnLine GetbyID(string LineID)
        {
            List <Line> lstLine    = null;
            Line        line       = null;
            ReturnLine  ReturnLine = new ReturnLine();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tLine_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value = LineID.Trim();

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstLine = new List <Line>();
                                while (sqlDr.Read())
                                {
                                    line           = new Line();
                                    line.LineID    = sqlDr["LineID"].ToString();
                                    line.LineName  = sqlDr["LineName"].ToString();
                                    line.FactoryID = sqlDr["FactoryID"].ToString();
                                    line.isActive  = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstLine.Add(line);
                                }
                                ReturnLine.Code    = "00";
                                ReturnLine.Message = "Lấy dữ liệu thành công.";
                                ReturnLine.LstLine = lstLine;
                                ReturnLine.Total   = lstLine.Count;
                                //}
                            }
                            else
                            {
                                ReturnLine.Code    = "01";
                                ReturnLine.Message = "Không tồn tại bản ghi nào.";
                                ReturnLine.Total   = 0;
                                ReturnLine.LstLine = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ReturnLine.Code    = "99";
                ReturnLine.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                ReturnLine.Total   = 0;
                ReturnLine.LstLine = null;
                mylog4net.Error("", ex);
            }
            return(ReturnLine);
        }
        public ReturnFPBCheckingItem ListAll()
        {
            List <FPBCheckingItem> lstFPBCheckingItem    = null;
            FPBCheckingItem        FPBCheckingItem       = null;
            ReturnFPBCheckingItem  returnFPBCheckingItem = new ReturnFPBCheckingItem();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_FPBCheckingItem_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstFPBCheckingItem = new List <FPBCheckingItem>();
                                while (sqlDr.Read())
                                {
                                    FPBCheckingItem = new FPBCheckingItem();
                                    //FPBCheckingItem.IDFPBCheckingItem = int.Parse(sqlDr["IDFPBCheckingItem"].ToString());
                                    FPBCheckingItem.MachineID = sqlDr["MachineID"].ToString();
                                    //FPBCheckingItem.CheckingItemName = sqlDr["CheckingItemName"].ToString();
                                    FPBCheckingItem.FrequencyID = int.Parse(sqlDr["FrequencyID"].ToString());
                                    //FPBCheckingItem.isActive = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstFPBCheckingItem.Add(FPBCheckingItem);
                                }
                                returnFPBCheckingItem.Code               = "00";
                                returnFPBCheckingItem.Message            = "Lấy dữ liệu thành công.";
                                returnFPBCheckingItem.LstFPBCheckingItem = lstFPBCheckingItem;
                            }
                            else
                            {
                                returnFPBCheckingItem.Code               = "01";
                                returnFPBCheckingItem.Message            = "Không tồn tại bản ghi nào.";
                                returnFPBCheckingItem.Total              = 0;
                                returnFPBCheckingItem.LstFPBCheckingItem = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPBCheckingItem.Code               = "99";
                returnFPBCheckingItem.Message            = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPBCheckingItem.Total              = 0;
                returnFPBCheckingItem.LstFPBCheckingItem = null;
                mylog4net.Error("", ex);
            }
            return(returnFPBCheckingItem);
        }
Esempio n. 10
0
        public ReturnMachinePart GetbyID(int ID)
        {
            List <MachinePart> lstMachinePart    = null;
            MachinePart        machinePart       = null;
            ReturnMachinePart  returnMachinePart = new ReturnMachinePart();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tMachinePart_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = ID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachinePart = new List <MachinePart>();
                                while (sqlDr.Read())
                                {
                                    machinePart             = new MachinePart();
                                    machinePart.ID          = int.Parse(sqlDr["ID"].ToString());
                                    machinePart.Name        = sqlDr["Name"].ToString();
                                    machinePart.Description = sqlDr["Description"].ToString();
                                    machinePart.MachineType = int.Parse(sqlDr["MachineType"].ToString());
                                    machinePart.DateCreated = DateTime.Parse(sqlDr["DateCreated"].ToString());

                                    lstMachinePart.Add(machinePart);
                                }
                                returnMachinePart.Code           = "00";
                                returnMachinePart.Message        = "Lấy dữ liệu thành công.";
                                returnMachinePart.lstMachinePart = lstMachinePart;
                            }
                            else
                            {
                                returnMachinePart.Code           = "01";
                                returnMachinePart.Message        = "Không tồn tại bản ghi nào.";
                                returnMachinePart.Total          = 0;
                                returnMachinePart.lstMachinePart = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachinePart.Code           = "99";
                returnMachinePart.Message        = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachinePart.Total          = 0;
                returnMachinePart.lstMachinePart = null;
                mylog4net.Error("", ex);
            }
            return(returnMachinePart);
        }
Esempio n. 11
0
        public ReturnUserMenu GetByUserID(int UserID)
        {
            List <UserMenu> lstUserMenu    = null;
            UserMenu        userMenu       = null;
            ReturnUserMenu  returnUserMenu = new ReturnUserMenu();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tUserMenu_SelectByUserID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Int)).Value = UserID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstUserMenu = new List <UserMenu>();
                                while (sqlDr.Read())
                                {
                                    userMenu           = new UserMenu();
                                    userMenu.ID        = int.Parse(sqlDr["ID"].ToString());
                                    userMenu.Pemission = sqlDr["Pemission"].ToString();
                                    userMenu.UserID    = int.Parse(sqlDr["UserID"].ToString());
                                    userMenu.MenuID    = int.Parse(sqlDr["MenuID"].ToString());
                                    userMenu.MenuName  = sqlDr["MenuName"].ToString();
                                    lstUserMenu.Add(userMenu);
                                }
                                returnUserMenu.Code        = "00";
                                returnUserMenu.Message     = "Lấy dữ liệu thành công.";
                                returnUserMenu.lstUserMenu = lstUserMenu;
                            }
                            else
                            {
                                returnUserMenu.Code        = "01";
                                returnUserMenu.Message     = "Không tồn tại bản ghi nào.";
                                returnUserMenu.Total       = 0;
                                returnUserMenu.lstUserMenu = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnUserMenu.Code        = "99";
                returnUserMenu.Message     = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnUserMenu.Total       = 0;
                returnUserMenu.lstUserMenu = null;
                mylog4net.Error("", ex);
            }
            return(returnUserMenu);
        }
Esempio n. 12
0
        public ReturnUserMenu CheckPermission(int userID, int menuId, string UnumPermission)
        {
            List <UserMenu> lstUserMenu    = null;
            UserMenu        userMenu       = null;
            ReturnUserMenu  returnUserMenu = new ReturnUserMenu();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tUserMenu_CheckPermission";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Int)).Value = userID;
                        cmd.Parameters.Add(new SqlParameter("@MenuId", SqlDbType.Int)).Value = menuId;
                        cmd.Parameters.Add(new SqlParameter("@UnumPermission", SqlDbType.NVarChar)).Value = UnumPermission;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstUserMenu = new List <UserMenu>();
                                while (sqlDr.Read())
                                {
                                    userMenu           = new UserMenu();
                                    userMenu.ID        = int.Parse(sqlDr["ID"].ToString());
                                    userMenu.Pemission = sqlDr["Pemission"].ToString();
                                    userMenu.UserID    = int.Parse(sqlDr["UserID"].ToString());
                                    userMenu.MenuID    = int.Parse(sqlDr["MenuID"].ToString());
                                    lstUserMenu.Add(userMenu);
                                }
                                returnUserMenu.Code        = "00";
                                returnUserMenu.Message     = "Lấy dữ liệu thành công.";
                                returnUserMenu.lstUserMenu = lstUserMenu;
                            }
                            else
                            {
                                returnUserMenu.Code        = "01";
                                returnUserMenu.Message     = "Không tồn tại bản ghi nào.";
                                returnUserMenu.Total       = 0;
                                returnUserMenu.lstUserMenu = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnUserMenu.Code        = "99";
                returnUserMenu.Message     = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnUserMenu.Total       = 0;
                returnUserMenu.lstUserMenu = null;
                mylog4net.Error("", ex);
            }
            return(returnUserMenu);
        }
Esempio n. 13
0
        public ReturnMachineType MachineTypeAll()
        {
            List <MachineType> lstMachineType    = null;
            MachineType        machineType       = null;
            ReturnMachineType  returnMachineType = new ReturnMachineType();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineType_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;


                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineType = new List <MachineType>();
                                while (sqlDr.Read())
                                {
                                    machineType             = new MachineType();
                                    machineType.ID          = int.Parse(sqlDr["ID"].ToString());
                                    machineType.TypeName    = sqlDr["TypeName"].ToString();
                                    machineType.Description = sqlDr["Description"].ToString();
                                    machineType.isActive    = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());
                                    lstMachineType.Add(machineType);
                                }

                                returnMachineType.Total          = lstMachineType.Count;
                                returnMachineType.Code           = "00";
                                returnMachineType.Message        = "Lấy dữ liệu thành công.";
                                returnMachineType.lstMachineType = lstMachineType;
                            }
                            else
                            {
                                returnMachineType.Code           = "01";
                                returnMachineType.Message        = "Không tồn tại bản ghi nào.";
                                returnMachineType.Total          = 0;
                                returnMachineType.lstMachineType = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineType.Code           = "99";
                returnMachineType.Message        = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineType.Total          = 0;
                returnMachineType.lstMachineType = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineType);
        }
Esempio n. 14
0
        public ReturnMachineMtnFrequencyView MachineMtnFrequencyAll()
        {
            List <MachineMtnFrequencyView> lstMachineMtnFrequencyView    = null;
            MachineMtnFrequencyView        machineMtnFrequencyView       = null;
            ReturnMachineMtnFrequencyView  returnMachineMtnFrequencyView = new ReturnMachineMtnFrequencyView();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnFrequency_SelectAll";
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineMtnFrequencyView = new List <MachineMtnFrequencyView>();
                                while (sqlDr.Read())
                                {
                                    machineMtnFrequencyView             = new MachineMtnFrequencyView();
                                    machineMtnFrequencyView.MachineID   = sqlDr["MachineID"].ToString();
                                    machineMtnFrequencyView.Daily       = Convert.ToInt16(sqlDr["TanSuat1"].ToString());
                                    machineMtnFrequencyView.Weekly      = Convert.ToInt16(sqlDr["TanSuat2"].ToString());
                                    machineMtnFrequencyView.Monthly     = Convert.ToInt16(sqlDr["TanSuat3"].ToString());
                                    machineMtnFrequencyView.ThreeMonths = Convert.ToInt16(sqlDr["TanSuat4"].ToString());
                                    machineMtnFrequencyView.SixMonths   = Convert.ToInt16(sqlDr["TanSuat5"].ToString());
                                    machineMtnFrequencyView.Yearly      = Convert.ToInt16(sqlDr["TanSuat6"].ToString());
                                    lstMachineMtnFrequencyView.Add(machineMtnFrequencyView);
                                }
                                returnMachineMtnFrequencyView.Code    = "00";
                                returnMachineMtnFrequencyView.Message = "Lấy dữ liệu thành công.";
                                returnMachineMtnFrequencyView.lstMachineMtnFrequencyView = lstMachineMtnFrequencyView;
                            }
                            else
                            {
                                returnMachineMtnFrequencyView.Code    = "01";
                                returnMachineMtnFrequencyView.Message = "Không tồn tại bản ghi nào.";
                                returnMachineMtnFrequencyView.Total   = 0;
                                returnMachineMtnFrequencyView.lstMachineMtnFrequencyView = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnFrequencyView.Code    = "99";
                returnMachineMtnFrequencyView.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnFrequencyView.Total   = 0;
                returnMachineMtnFrequencyView.lstMachineMtnFrequencyView = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineMtnFrequencyView);
        }
Esempio n. 15
0
        public ReturnRole ListByUserID(int userID)
        {
            List <Role> lstRole    = null;
            Role        role       = null;
            ReturnRole  returnRole = new ReturnRole();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "[sp_tRole_SelectByUserID]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Int)).Value = userID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstRole = new List <Role>();
                                while (sqlDr.Read())
                                {
                                    role          = new Role();
                                    role.ID       = int.Parse(sqlDr["ID"].ToString());
                                    role.RoleName = sqlDr["RoleName"].ToString();
                                    role.Title    = sqlDr["Title"].ToString();

                                    lstRole.Add(role);
                                }
                                returnRole.Code    = "00";
                                returnRole.Message = "Lấy dữ liệu thành công.";
                                returnRole.lstRole = lstRole;
                            }
                            else
                            {
                                returnRole.Code    = "01";
                                returnRole.Message = "Không tồn tại bản ghi nào.";
                                returnRole.Total   = 0;
                                returnRole.lstRole = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnRole.Code    = "99";
                returnRole.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnRole.Total   = 0;
                returnRole.lstRole = null;
                mylog4net.Error("", ex);
            }
            return(returnRole);
        }
Esempio n. 16
0
        public ReturnMachineTypeFrequency GetbyMachineTypeID(int MachineTypeID)
        {
            List <MachineTypeFrequency> lstMachineTypeFrequency    = null;
            MachineTypeFrequency        machineTypeFrequency       = null;
            ReturnMachineTypeFrequency  returnMachineTypeFrequency = new ReturnMachineTypeFrequency();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tMachineTypeFrequency_SelectByMachineTypeID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.Int)).Value = MachineTypeID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineTypeFrequency = new List <MachineTypeFrequency>();
                                while (sqlDr.Read())
                                {
                                    machineTypeFrequency               = new MachineTypeFrequency();
                                    machineTypeFrequency.ID            = Convert.ToInt16(sqlDr["ID"].ToString());
                                    machineTypeFrequency.MachineTypeID = Convert.ToInt32(sqlDr["MachineTypeID"].ToString());
                                    machineTypeFrequency.FrequencyID   = Convert.ToInt16(sqlDr["FrequencyID"].ToString());

                                    lstMachineTypeFrequency.Add(machineTypeFrequency);
                                }
                                returnMachineTypeFrequency.Code    = "00";
                                returnMachineTypeFrequency.Message = "Lấy dữ liệu thành công.";
                                returnMachineTypeFrequency.lstMachineTypeFrequency = lstMachineTypeFrequency;
                                returnMachineTypeFrequency.Total = lstMachineTypeFrequency.Count;
                            }
                            else
                            {
                                returnMachineTypeFrequency.Code    = "01";
                                returnMachineTypeFrequency.Message = "Không tồn tại bản ghi nào.";
                                returnMachineTypeFrequency.Total   = 0;
                                returnMachineTypeFrequency.lstMachineTypeFrequency = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineTypeFrequency.Code    = "99";
                returnMachineTypeFrequency.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineTypeFrequency.Total   = 0;
                returnMachineTypeFrequency.lstMachineTypeFrequency = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineTypeFrequency);
        }
Esempio n. 17
0
        public ReturnUserPermission ListAllControllerName_PermissionByUserID(int userID)
        {
            List <UserPermission> lstUserPermission = null;
            UserPermission        userPermission    = null;
            ReturnUserPermission  returnUserMenu    = new ReturnUserPermission();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tMenu_ListAllControllerName_PermissionByUserID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Int)).Value = userID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstUserPermission = new List <UserPermission>();
                                while (sqlDr.Read())
                                {
                                    userPermission                = new UserPermission();
                                    userPermission.RoleID         = int.Parse(sqlDr["RoleID"].ToString());
                                    userPermission.MenuID         = int.Parse(sqlDr["MenuID"].ToString());
                                    userPermission.Permission     = sqlDr["Permission"].ToString();
                                    userPermission.ControllerName = sqlDr["ControllerName"].ToString();
                                    lstUserPermission.Add(userPermission);
                                }
                                returnUserMenu.Code              = "00";
                                returnUserMenu.Message           = "Lấy dữ liệu thành công.";
                                returnUserMenu.lstUserPermission = lstUserPermission;
                            }
                            else
                            {
                                returnUserMenu.Code              = "01";
                                returnUserMenu.Message           = "Không tồn tại bản ghi nào.";
                                returnUserMenu.Total             = 0;
                                returnUserMenu.lstUserPermission = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnUserMenu.Code              = "99";
                returnUserMenu.Message           = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnUserMenu.Total             = 0;
                returnUserMenu.lstUserPermission = null;
                mylog4net.Error("", ex);
            }
            return(returnUserMenu);
        }
Esempio n. 18
0
        public ReturnToolTypeList GetbyID(string ToolTypeID)
        {
            List <ToolTypeList> lstToolTypeList    = null;
            ToolTypeList        toolTypeList       = null;
            ReturnToolTypeList  returnToolTypeList = new ReturnToolTypeList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tToolTypeList_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ToolTypeID", SqlDbType.VarChar)).Value = ToolTypeID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstToolTypeList = new List <ToolTypeList>();
                                while (sqlDr.Read())
                                {
                                    toolTypeList              = new ToolTypeList();
                                    toolTypeList.ToolTypeID   = sqlDr["ToolTypeID"].ToString();
                                    toolTypeList.ToolTypeName = sqlDr["ToolTypeName"].ToString();
                                    toolTypeList.isActive     = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstToolTypeList.Add(toolTypeList);
                                }
                                returnToolTypeList.Code            = "00";
                                returnToolTypeList.Message         = "Lấy dữ liệu thành công.";
                                returnToolTypeList.LstToolTypeList = lstToolTypeList;
                            }
                            else
                            {
                                returnToolTypeList.Code            = "01";
                                returnToolTypeList.Message         = "Không tồn tại bản ghi nào.";
                                returnToolTypeList.Total           = 0;
                                returnToolTypeList.LstToolTypeList = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnToolTypeList.Code            = "99";
                returnToolTypeList.Message         = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnToolTypeList.Total           = 0;
                returnToolTypeList.LstToolTypeList = null;
                mylog4net.Error("", ex);
            }
            return(returnToolTypeList);
        }
Esempio n. 19
0
        public ReturnMachineMtn CountMachineMtByMachineID(string machineID)
        {
            List <MachineMtn> lstMachineMtn    = null;
            MachineMtn        machineMtn       = null;
            ReturnMachineMtn  returnMachineMtn = new ReturnMachineMtn();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtn_CountByMachineID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.VarChar)).Value = machineID;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineMtn = new List <MachineMtn>();
                                while (sqlDr.Read())
                                {
                                    returnMachineMtn.Total    = Convert.ToInt16(sqlDr[0].ToString());
                                    returnMachineMtn.UserID   = MyShareInfo.ID;
                                    returnMachineMtn.UserName = MyShareInfo.UserName;
                                }
                                returnMachineMtn.Code          = "00";
                                returnMachineMtn.Message       = "Lấy dữ liệu thành công.";
                                returnMachineMtn.lstMachineMtn = lstMachineMtn;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnMachineMtn.Code          = "01";
                                returnMachineMtn.Message       = "Không tồn tại bản ghi nào.";
                                returnMachineMtn.Total         = 0;
                                returnMachineMtn.lstMachineMtn = null;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtn.Code          = "99";
                returnMachineMtn.Message       = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtn.Total         = 0;
                returnMachineMtn.lstMachineMtn = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineMtn);
        }
Esempio n. 20
0
        public ReturnUser SearchByUserName(string where)
        {
            List <User> lstUser    = null;
            User        user       = null;
            ReturnUser  returnUser = new ReturnUser();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tUserMenu_SearchByUserName";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@where", SqlDbType.NVarChar)).Value = where;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstUser = new List <User>();
                                while (sqlDr.Read())
                                {
                                    user          = new User();
                                    user.ID       = int.Parse(sqlDr["UserID"].ToString());
                                    user.UserName = sqlDr["UserName"].ToString();
                                    lstUser.Add(user);
                                }
                                returnUser.Code    = "00";
                                returnUser.Message = "Lấy dữ liệu thành công.";
                                returnUser.lstUser = lstUser;
                            }
                            else
                            {
                                returnUser.Code    = "01";
                                returnUser.Message = "Không tồn tại bản ghi nào.";
                                returnUser.Total   = 0;
                                returnUser.lstUser = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnUser.Code    = "99";
                returnUser.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnUser.Total   = 0;
                returnUser.lstUser = null;
                mylog4net.Error("", ex);
            }
            return(returnUser);
        }
Esempio n. 21
0
        public ReturnMachine CountbyLineID(string LineID)
        {
            List <Machine> lstMachine    = null;
            Machine        machine       = null;
            ReturnMachine  returnMachine = new ReturnMachine();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tMachineList_CountbyLineID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value = LineID.Trim();

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                while (sqlDr.Read())
                                {
                                    returnMachine.lstMachine = null;
                                    returnMachine.Total      = Convert.ToInt16(sqlDr[0].ToString());
                                }
                                returnMachine.Code    = "00";
                                returnMachine.Message = "Lấy dữ liệu thành công.";


                                //}
                            }
                            else
                            {
                                returnMachine.Code       = "01";
                                returnMachine.Message    = "Không tồn tại bản ghi nào.";
                                returnMachine.Total      = 0;
                                returnMachine.lstMachine = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachine.Code       = "99";
                returnMachine.Message    = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachine.Total      = 0;
                returnMachine.lstMachine = null;
                mylog4net.Error("", ex);
            }
            return(returnMachine);
        }
        public ReturnMachineMtnContentList CountbyCondition(MachineMtnContentList machineMtnContentList)
        {
            List <MachineMtnContentList> lstMachineMtnContentList    = null;
            ReturnMachineMtnContentList  returnMachineMtnContentList = new ReturnMachineMtnContentList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnContentList_CountbyCondition";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.Int)).Value   = machineMtnContentList.MachineTypeID;
                        cmd.Parameters.Add(new SqlParameter("@MachinePartID", SqlDbType.Int)).Value   = machineMtnContentList.MachinePartID;
                        cmd.Parameters.Add(new SqlParameter("@ContentMtn", SqlDbType.NVarChar)).Value = machineMtnContentList.ContentMtn;
                        cmd.Parameters.Add(new SqlParameter("@FrequencyID", SqlDbType.Int)).Value     = machineMtnContentList.FrequencyID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                //lstMachineMtnContentList = new List<MachineMtnContentList>();
                                while (sqlDr.Read())
                                {
                                    returnMachineMtnContentList.Total = Convert.ToInt16(sqlDr[0].ToString());
                                }
                                returnMachineMtnContentList.Code    = "00";
                                returnMachineMtnContentList.Message = "Lấy dữ liệu thành công.";
                                returnMachineMtnContentList.lstMachineMtnContentList = lstMachineMtnContentList;
                            }
                            else
                            {
                                returnMachineMtnContentList.Code    = "01";
                                returnMachineMtnContentList.Message = "Không tồn tại bản ghi nào.";
                                returnMachineMtnContentList.Total   = 0;
                                returnMachineMtnContentList.lstMachineMtnContentList = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnContentList.Code    = "99";
                returnMachineMtnContentList.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnContentList.Total   = 0;
                returnMachineMtnContentList.lstMachineMtnContentList = null;
                mylog4net.Error("public ReturnMachineMtnContentList CountbyCondition(MachineMtnContentList machineMtnContentList) :", ex);
            }
            return(returnMachineMtnContentList);
        }
        public ReturnProductionControl CountBySelection(string where)
        {
            List <ProductionControl> lstProductionControl    = null;
            ReturnProductionControl  returnProductionControl = new ReturnProductionControl();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProductionControl_CountBySelection";
                        cmd.CommandType = CommandType.StoredProcedure;
                        //cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.NVarChar)).Value = productionControl.MachineID;
                        //cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.NVarChar)).Value = productionControl.ProgramName;
                        //cmd.Parameters.Add(new SqlParameter("@PdtCtrlDateTime", SqlDbType.VarChar)).Value = productionControl.PdtCtrlDateTime;
                        cmd.Parameters.Add(new SqlParameter("@where", SqlDbType.NVarChar)).Value = where;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProductionControl = new List <ProductionControl>();
                                while (sqlDr.Read())
                                {
                                    returnProductionControl.Total = Convert.ToInt16(sqlDr[0].ToString());
                                }
                                returnProductionControl.Code    = "00";
                                returnProductionControl.Message = "Lấy dữ liệu thành công.";
                                returnProductionControl.lstProductionControl = lstProductionControl;
                            }
                            else
                            {
                                returnProductionControl.Code    = "01";
                                returnProductionControl.Message = "Không tồn tại bản ghi nào.";
                                returnProductionControl.Total   = 0;
                                returnProductionControl.lstProductionControl = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProductionControl.Code    = "99";
                returnProductionControl.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProductionControl.Total   = 0;
                returnProductionControl.lstProductionControl = null;
                mylog4net.Error("public ReturnProductionControl CountProductionControlBySelection(ProductionControl productionControl) ", ex);
            }
            return(returnProductionControl);
        }
Esempio n. 24
0
        public ReturnMachineMtnDetail CountbyMachineMtnContentID(int machineMtnContentID)
        {
            //List<int> lstint = null;
            ReturnMachineMtnDetail returnMachineMtnDetail = new ReturnMachineMtnDetail();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnDetail_CountbyMachineMtnContentID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineMtnContentID", SqlDbType.Int)).Value = machineMtnContentID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                //lstint = new List<int>();
                                while (sqlDr.Read())
                                {
                                    returnMachineMtnDetail.Total = Convert.ToInt16(sqlDr[0].ToString());
                                }
                                returnMachineMtnDetail.Code                = "00";
                                returnMachineMtnDetail.Message             = "Lấy dữ liệu thành công.";
                                returnMachineMtnDetail.lstMachineMtnDetail = null;
                            }
                            else
                            {
                                returnMachineMtnDetail.Code                = "01";
                                returnMachineMtnDetail.Message             = "Không tồn tại bản ghi nào.";
                                returnMachineMtnDetail.Total               = 0;
                                returnMachineMtnDetail.lstMachineMtnDetail = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnDetail.Code                = "99";
                returnMachineMtnDetail.Message             = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnDetail.Total               = 0;
                returnMachineMtnDetail.lstMachineMtnDetail = null;
                mylog4net.Error("public ReturnMachineMtnDetail CountbyCondition(int machineMtnContentID) :", ex);
            }
            return(returnMachineMtnDetail);
        }
        //public ReturnProgramPdtCtrlHistory SearchProgramPdtCtrlHistory(ReturnProgramPdtCtrlHistory searchProgramPdtCtrlHistory, int pageSize)
        //{
        //    List<ProgramPdtCtrlHistory> lstProgramPdtCtrlHistory = null;
        //    ProgramPdtCtrlHistory programPdtCtrlHistory = null;
        //    ReturnProgramPdtCtrlHistory returnProgramPdtCtrlHistory = new ReturnProgramPdtCtrlHistory();
        //    try
        //    {
        //        using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
        //        {
        //            using (SqlCommand cmd = new SqlCommand("", sqlConnection))
        //            {
        //                cmd.CommandText = "sp_tProgramPdtCtrlHistory_Search";
        //                cmd.CommandType = CommandType.StoredProcedure;
        //                cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value = searchProgramPdtCtrlHistory.aProgramPdtCtrlHistory.ProgramName;
        //                cmd.Parameters.Add(new SqlParameter("@Parameter", SqlDbType.NVarChar)).Value = searchProgramPdtCtrlHistory.aProgramPdtCtrlHistory.Parameter;
        //                cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.NVarChar)).Value = searchProgramPdtCtrlHistory.aProgramPdtCtrlHistory.ControlItem;

        //                cmd.Parameters.Add(new SqlParameter("@pageNumber", SqlDbType.Int)).Value = searchProgramPdtCtrlHistory.PageNumber;
        //                cmd.Parameters.Add(new SqlParameter("@pageSize", SqlDbType.Int)).Value = pageSize;
        //                cmd.Parameters.Add("@totalRow", SqlDbType.Int).Direction = ParameterDirection.Output;

        //                using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
        //                {
        //                    if (sqlDr.HasRows)
        //                    {
        //                        lstProgramPdtCtrlHistory = new List<ProgramPdtCtrlHistory>();
        //                        while (sqlDr.Read())
        //                        {
        //                            programPdtCtrlHistory = new ProgramPdtCtrlHistory();
        //                            programPdtCtrlHistory.ProgramName = sqlDr["ProgramName"].ToString();
        //                            programPdtCtrlHistory.Parameter = sqlDr["Parameter"].ToString();
        //                            programPdtCtrlHistory.ControlItem = sqlDr["ControlItem"].ToString();
        //                            programPdtCtrlHistory.SpecDisplay = sqlDr["SpecDisplay"].ToString();
        //                            programPdtCtrlHistory.Unit = sqlDr["Unit"].ToString();
        //                            programPdtCtrlHistory.UpperLimit = sqlDr["UpperLimit"].ToString();
        //                            programPdtCtrlHistory.LowerLimit = sqlDr["LowerLimit"].ToString();
        //                            programPdtCtrlHistory.ColumnName = sqlDr["ColumnName"].ToString();
        //                            programPdtCtrlHistory.OperatorID = Convert.ToInt32(sqlDr["OperatorID"].ToString());
        //                            programPdtCtrlHistory.HistoryOperatorID = Convert.ToInt32(sqlDr["HistoryOperatorID"].ToString());
        //                            programPdtCtrlHistory.ItemName = sqlDr["ItemName"].ToString();

        //                            lstProgramPdtCtrlHistory.Add(programPdtCtrlHistory);
        //                        }
        //                        returnProgramPdtCtrlHistory.Code = "00";
        //                        returnProgramPdtCtrlHistory.Message = "Lấy dữ liệu thành công.";
        //                        returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = lstProgramPdtCtrlHistory;
        //                    }
        //                    else
        //                    {
        //                        returnProgramPdtCtrlHistory.Code = "01";
        //                        returnProgramPdtCtrlHistory.Message = "Không tồn tại bản ghi nào.";
        //                        returnProgramPdtCtrlHistory.Total = 0;
        //                        returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
        //                    }
        //                }
        //                //get return Totalpage value.
        //                if (returnProgramPdtCtrlHistory.Code == "00")
        //                    returnProgramPdtCtrlHistory.Total = Convert.ToInt32(cmd.Parameters["@totalRow"].Value);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        returnProgramPdtCtrlHistory.Code = "99";
        //        returnProgramPdtCtrlHistory.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
        //        returnProgramPdtCtrlHistory.Total = 0;
        //        returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
        //        mylog4net.Error("", ex);
        //    }
        //    return returnProgramPdtCtrlHistory;
        //}

        public ReturnProgramPdtCtrlHistory SearchProgramPdtCtrlHistory(ProgramPdtCtrlHistory searchProgramPdtCtrlHistory, int pageNumber, int pageSize)
        {
            List <ProgramPdtCtrlHistory> lstProgramPdtCtrlHistory    = null;
            ProgramPdtCtrlHistory        programPdtCtrlHistory       = null;
            ReturnProgramPdtCtrlHistory  returnProgramPdtCtrlHistory = new ReturnProgramPdtCtrlHistory();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProgramPdtCtrlHistory_Search";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value  = searchProgramPdtCtrlHistory.ProgramName;
                        cmd.Parameters.Add(new SqlParameter("@Part", SqlDbType.NVarChar)).Value        = searchProgramPdtCtrlHistory.Part;
                        cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.NVarChar)).Value = searchProgramPdtCtrlHistory.ControlItem;

                        cmd.Parameters.Add(new SqlParameter("@pageNumber", SqlDbType.Int)).Value = pageNumber;
                        cmd.Parameters.Add(new SqlParameter("@pageSize", SqlDbType.Int)).Value   = pageSize;
                        cmd.Parameters.Add("@totalRow", SqlDbType.Int).Direction = ParameterDirection.Output;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProgramPdtCtrlHistory = new List <ProgramPdtCtrlHistory>();
                                while (sqlDr.Read())
                                {
                                    programPdtCtrlHistory             = new ProgramPdtCtrlHistory();
                                    programPdtCtrlHistory.ProgramName = sqlDr["ProgramName"].ToString();
                                    programPdtCtrlHistory.Parameter   = sqlDr["Parameter"].ToString();
                                    programPdtCtrlHistory.ControlItem = sqlDr["ControlItem"].ToString();
                                    programPdtCtrlHistory.SpecDisplay = sqlDr["SpecDisplay"].ToString();
                                    programPdtCtrlHistory.Unit        = sqlDr["Unit"].ToString();
                                    programPdtCtrlHistory.UpperLimit  = sqlDr["UpperLimit"].ToString();
                                    programPdtCtrlHistory.LowerLimit  = sqlDr["LowerLimit"].ToString();
                                    programPdtCtrlHistory.ColumnName  = sqlDr["ColumnName"].ToString();
                                    if (!String.IsNullOrEmpty(sqlDr["HistoryOperatorID"].ToString()))
                                    {
                                        programPdtCtrlHistory.HistoryOperatorID   = Int32.Parse(sqlDr["HistoryOperatorID"].ToString());//Convert.ToInt32(sqlDr["HistoryOperatorID"].ToString());
                                        programPdtCtrlHistory.HistoryOperatorName = (new UserDB()).getUserNameByID(Convert.ToInt32(programPdtCtrlHistory.HistoryOperatorID));
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["OperatorID"].ToString()))
                                    {
                                        programPdtCtrlHistory.OperatorID   = Int32.Parse(sqlDr["OperatorID"].ToString());//Convert.ToInt32(sqlDr["OperatorID"].ToString());
                                        programPdtCtrlHistory.OperatorName = (new UserDB()).getUserNameByID(Convert.ToInt32(programPdtCtrlHistory.OperatorID));
                                    }
                                    programPdtCtrlHistory.CreatedDate = DateTime.Parse(sqlDr["CreatedDate"].ToString());
                                    programPdtCtrlHistory.HistoryDate = DateTime.Parse(sqlDr["HistoryDate"].ToString());
                                    programPdtCtrlHistory.StatusCRUD  = sqlDr["StatusCRUD"].ToString();

                                    lstProgramPdtCtrlHistory.Add(programPdtCtrlHistory);
                                }
                                returnProgramPdtCtrlHistory.Code    = "00";
                                returnProgramPdtCtrlHistory.Message = "Lấy dữ liệu thành công.";
                                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = lstProgramPdtCtrlHistory;
                            }
                            else
                            {
                                returnProgramPdtCtrlHistory.Code    = "01";
                                returnProgramPdtCtrlHistory.Message = "Không tồn tại bản ghi nào.";
                                returnProgramPdtCtrlHistory.Total   = 0;
                                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
                            }
                        }
                        //get return Totalpage value.
                        if (returnProgramPdtCtrlHistory.Code == "00")
                        {
                            returnProgramPdtCtrlHistory.Total = Convert.ToInt32(cmd.Parameters["@totalRow"].Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProgramPdtCtrlHistory.Code    = "99";
                returnProgramPdtCtrlHistory.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProgramPdtCtrlHistory.Total   = 0;
                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
                mylog4net.Error("", ex);
            }
            return(returnProgramPdtCtrlHistory);
        }
        public ReturnProgramPdtCtrlHistory GetbyKey(ProgramPdtCtrlHistory p)
        {
            List <ProgramPdtCtrlHistory> lstProgramPdtCtrlHistory    = null;
            ProgramPdtCtrlHistory        programPdtCtrlHistory       = null;
            ReturnProgramPdtCtrlHistory  returnProgramPdtCtrlHistory = new ReturnProgramPdtCtrlHistory();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tProgramPdtCtrlHistory_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value  = p.ProgramName;
                        cmd.Parameters.Add(new SqlParameter("@Parameter", SqlDbType.NVarChar)).Value   = p.Parameter;
                        cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.NVarChar)).Value = p.ControlItem;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProgramPdtCtrlHistory = new List <ProgramPdtCtrlHistory>();
                                while (sqlDr.Read())
                                {
                                    programPdtCtrlHistory             = new ProgramPdtCtrlHistory();
                                    programPdtCtrlHistory.ProgramName = sqlDr["ProgramName"].ToString();
                                    programPdtCtrlHistory.Parameter   = sqlDr["Parameter"].ToString();
                                    programPdtCtrlHistory.ControlItem = sqlDr["ControlItem"].ToString();
                                    programPdtCtrlHistory.ColumnName  = sqlDr["ColumnName"].ToString();
                                    programPdtCtrlHistory.Unit        = sqlDr["Unit"].ToString();
                                    programPdtCtrlHistory.SpecDisplay = sqlDr["SpecDisplay"].ToString();
                                    programPdtCtrlHistory.LowerLimit  = sqlDr["LowerLimit"].ToString();
                                    programPdtCtrlHistory.UpperLimit  = sqlDr["UpperLimit"].ToString();

                                    if (!String.IsNullOrEmpty(sqlDr["HistoryOperatorID"].ToString()))
                                    {
                                        programPdtCtrlHistory.HistoryOperatorID   = Int32.Parse(sqlDr["HistoryOperatorID"].ToString());//Convert.ToInt32(sqlDr["HistoryOperatorID"].ToString());
                                        programPdtCtrlHistory.HistoryOperatorName = (new UserDB()).getUserNameByID(Convert.ToInt32(programPdtCtrlHistory.HistoryOperatorID));
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["OperatorID"].ToString()))
                                    {
                                        programPdtCtrlHistory.OperatorID   = Int32.Parse(sqlDr["OperatorID"].ToString());//Convert.ToInt32(sqlDr["OperatorID"].ToString());
                                        programPdtCtrlHistory.OperatorName = (new UserDB()).getUserNameByID(Convert.ToInt32(programPdtCtrlHistory.OperatorID));
                                    }
                                    programPdtCtrlHistory.ItemName = sqlDr["ItemName"].ToString();
                                    lstProgramPdtCtrlHistory.Add(programPdtCtrlHistory);
                                }
                                returnProgramPdtCtrlHistory.Code    = "00";
                                returnProgramPdtCtrlHistory.Message = "Lấy dữ liệu thành công.";
                                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = lstProgramPdtCtrlHistory;
                                returnProgramPdtCtrlHistory.Total = lstProgramPdtCtrlHistory.Count;
                                //}
                            }
                            else
                            {
                                returnProgramPdtCtrlHistory.Code    = "01";
                                returnProgramPdtCtrlHistory.Message = "Không tồn tại bản ghi nào.";
                                returnProgramPdtCtrlHistory.Total   = 0;
                                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProgramPdtCtrlHistory.Code    = "99";
                returnProgramPdtCtrlHistory.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProgramPdtCtrlHistory.Total   = 0;
                returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = null;
                mylog4net.Error("", ex);
            }
            return(returnProgramPdtCtrlHistory);
        }
        public ReturnConditionSetting GetbyID(int ID)
        {
            List <ConditionSetting> lstConditionSetting    = null;
            ConditionSetting        conditionSetting       = null;
            ReturnConditionSetting  returnConditionSetting = new ReturnConditionSetting();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tProductionControlList_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = ID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstConditionSetting = new List <ConditionSetting>();
                                while (sqlDr.Read())
                                {
                                    conditionSetting                 = new ConditionSetting();
                                    conditionSetting.ID              = Convert.ToInt32(sqlDr["ID"].ToString());
                                    conditionSetting.LineID          = sqlDr["LineID"].ToString();
                                    conditionSetting.MachineTypeID   = Convert.ToInt32(sqlDr["MachineTypeID"].ToString());
                                    conditionSetting.MachineTypeName = sqlDr["TypeName"].ToString();
                                    conditionSetting.PatternCode     = sqlDr["PatternCode"].ToString();
                                    conditionSetting.ControlItem     = sqlDr["ControlItem"].ToString();
                                    conditionSetting.SpecDisplay     = sqlDr["SpecDisplay"].ToString();
                                    conditionSetting.Unit            = sqlDr["Unit"].ToString();
                                    conditionSetting.LowerLimit      = float.Parse(sqlDr["LowerLimit"].ToString());
                                    conditionSetting.UpperLimit      = float.Parse(sqlDr["UpperLimit"].ToString());

                                    lstConditionSetting.Add(conditionSetting);
                                }
                                returnConditionSetting.Code    = "00";
                                returnConditionSetting.Message = "Lấy dữ liệu thành công.";
                                //_ReturnTool.Total = Convert.ToInt32(cmd.Parameters["P_TOTAL"].Value.ToString());
                                returnConditionSetting.lstConditionSetting = lstConditionSetting;
                                //}
                            }
                            else
                            {
                                returnConditionSetting.Code                = "01";
                                returnConditionSetting.Message             = "Không tồn tại bản ghi nào.";
                                returnConditionSetting.Total               = 0;
                                returnConditionSetting.lstConditionSetting = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnConditionSetting.Code                = "99";
                returnConditionSetting.Message             = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnConditionSetting.Total               = 0;
                returnConditionSetting.lstConditionSetting = null;
                mylog4net.Error("", ex);
            }
            return(returnConditionSetting);
        }
Esempio n. 28
0
        public ReturnMachineMtn SelectByPage(string where, int pageNumber, int pageSize)
        {
            List <MachineMtn> lstMachineMtn    = null;
            MachineMtn        machineMtn       = null;
            ReturnMachineMtn  returnMachineMtn = new ReturnMachineMtn();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtn_SearchBypage";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@where", SqlDbType.NVarChar)).Value = where;
                        //paging
                        cmd.Parameters.Add(new SqlParameter("@pageNumber", SqlDbType.Int)).Value = pageNumber;
                        cmd.Parameters.Add(new SqlParameter("@pageSize", SqlDbType.Int)).Value   = pageSize;
                        cmd.Parameters.Add("@totalRow", SqlDbType.Int).Direction = ParameterDirection.Output;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineMtn = new List <MachineMtn>();
                                while (sqlDr.Read())
                                {
                                    machineMtn              = new MachineMtn();
                                    machineMtn.ID           = Convert.ToInt16(sqlDr["ID"].ToString());
                                    machineMtn.MachineID    = sqlDr["MachineID"].ToString();
                                    machineMtn.MachineName  = sqlDr["MachineName"].ToString();
                                    machineMtn.OperatorID   = sqlDr["OperatorID"].ToString();
                                    machineMtn.OperatorName = sqlDr["UserName"].ToString();   // UserName in Sql = operatorName in C#
                                    if (!String.IsNullOrEmpty(sqlDr["Shift"].ToString()))
                                    {
                                        machineMtn.Shift = Convert.ToInt16(sqlDr["Shift"].ToString());
                                    }
                                    machineMtn.MaintenanceDate = Convert.ToDateTime(sqlDr["MaintenanceDate"].ToString());
                                    machineMtn.FrequencyID     = Convert.ToInt16(sqlDr["FrequencyID"].ToString());
                                    machineMtn.Result          = sqlDr["Result"].ToString();
                                    machineMtn.ResultContents  = sqlDr["ResultContents"].ToString();
                                    if (!String.IsNullOrEmpty(sqlDr["Month"].ToString()))
                                    {
                                        machineMtn.Month = Convert.ToInt16(sqlDr["Month"].ToString());
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["Year"].ToString()))
                                    {
                                        machineMtn.Year = Convert.ToInt16(sqlDr["Year"].ToString());
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["Week"].ToString()))
                                    {
                                        machineMtn.Week = Convert.ToInt16(sqlDr["Week"].ToString());
                                    }
                                    machineMtn.CheckerID = Convert.ToInt16(sqlDr["CheckerID"].ToString());
                                    //get Checker name.
                                    int _checkerID = 0;
                                    machineMtn.CheckerName = "";
                                    if (Int32.TryParse(sqlDr["CheckerID"].ToString(), out _checkerID))
                                    {
                                        ReturnUser returnUser = (new UserDB()).GetbyID(_checkerID);
                                        if (returnUser.Code == "00")
                                        {
                                            machineMtn.CheckerName = returnUser.lstUser[0].UserName;
                                        }
                                    }
                                    machineMtn.CheckerResult = sqlDr["CheckerResult"].ToString();
                                    lstMachineMtn.Add(machineMtn);
                                }
                                returnMachineMtn.Code          = "00";
                                returnMachineMtn.Message       = "Lấy dữ liệu thành công.";
                                returnMachineMtn.lstMachineMtn = lstMachineMtn;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnMachineMtn.Code          = "01";
                                returnMachineMtn.Message       = "Không tồn tại bản ghi nào.";
                                returnMachineMtn.Total         = 0;
                                returnMachineMtn.lstMachineMtn = null;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                        }
                        //paging.
                        if (returnMachineMtn.Code == "00")
                        {
                            returnMachineMtn.Total = Convert.ToInt32(cmd.Parameters["@totalRow"].Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtn.Code          = "99";
                returnMachineMtn.Message       = "Lỗi xử lý dữ liệu/Error: " + ex.ToString();
                returnMachineMtn.Total         = 0;
                returnMachineMtn.lstMachineMtn = null;
                mylog4net.Error("public ReturnMachineMtn SelectByCondition(string where, int pageSize) ", ex);
            }
            return(returnMachineMtn);
        }
        public ReturnProductionControl SearchProductionControl(string where)
        {
            List <ProductionControl> lstProductionControl    = null;
            ProductionControl        productionControl       = null;
            ReturnProductionControl  returnProductionControl = new ReturnProductionControl();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProductionControl_SearchProductionControl";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@where", SqlDbType.NVarChar)).Value = where;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProductionControl = new List <ProductionControl>();
                                while (sqlDr.Read())
                                {
                                    productionControl                 = new ProductionControl();
                                    productionControl.ID              = int.Parse(sqlDr["ID"].ToString());
                                    productionControl.IndicationID    = sqlDr["IndicationID"].ToString();
                                    productionControl.MachineID       = sqlDr["MachineID"].ToString();
                                    productionControl.MachineName     = sqlDr["MachineName"].ToString();
                                    productionControl.PdtCtrlDateTime = Convert.ToDateTime(sqlDr["PdtCtrlDateTime"].ToString());
                                    productionControl.UserID          = sqlDr["UserID"].ToString();
                                    productionControl.UserName        = sqlDr["UserName"].ToString();
                                    productionControl.ItemName        = sqlDr["ItemName"].ToString();
                                    productionControl.ItemCode        = sqlDr["ItemCode"].ToString();
                                    productionControl.BatchNo         = sqlDr["BatchNo"].ToString();
                                    productionControl.SeqNo           = sqlDr["SeqNo"].ToString();
                                    productionControl.Result          = sqlDr["Result"].ToString();
                                    productionControl.ProgramName     = sqlDr["ProgramName"].ToString();
                                    lstProductionControl.Add(productionControl);
                                }
                                returnProductionControl.Code    = "00";
                                returnProductionControl.Message = "Lấy dữ liệu thành công.";
                                returnProductionControl.lstProductionControl = lstProductionControl;
                                returnProductionControl.userID   = MyShareInfo.ID;
                                returnProductionControl.UserName = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnProductionControl.Code    = "01";
                                returnProductionControl.Message = "Không tồn tại bản ghi nào.";
                                returnProductionControl.Total   = 0;
                                returnProductionControl.lstProductionControl = null;
                                returnProductionControl.userID   = MyShareInfo.ID;
                                returnProductionControl.UserName = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProductionControl.Code    = "99";
                returnProductionControl.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProductionControl.Total   = 0;
                returnProductionControl.lstProductionControl = null;
                mylog4net.Error("", ex);
            }
            return(returnProductionControl);
        }
Esempio n. 30
0
        //public ReturnMachineMtn DeleteMachineMtnDetailByID(int _ID)
        //{
        //    //ReturnMachineMtn returnMachineMtn = new ReturnMachineMtn();
        //    //try
        //    //{
        //    //    // Gọi vào DB để lấy dữ liệu.
        //    //    using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
        //    //    {
        //    //        using (SqlCommand cmd = new SqlCommand("", sqlConnection))
        //    //        {
        //    //            cmd.CommandText = "sp_tMachineMtn_DeleteByID";
        //    //            cmd.CommandType = CommandType.StoredProcedure;
        //    //            cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = _ID;
        //    //            //cmd.Parameters.Add("@RETURN_CODE", SqlDbType.Int).Direction = ParameterDirection.Output;
        //    //            //int RETURN_CODE = Convert.ToInt32(cmd.Parameters["@RETURN_CODE"].Value);
        //    //            cmd.ExecuteNonQuery();
        //    //            returnMachineMtn.Code = "00";
        //    //            returnMachineMtn.Message = "Cập nhật dữ liệu thành công.";
        //    //        }
        //    //    }
        //    //}
        //    //catch (Exception ex)
        //    //{
        //    //    returnMachineMtn.Code = "99";
        //    //    returnMachineMtn.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
        //    //    returnMachineMtn.Total = 0;
        //    //    returnMachineMtn.lstMachineMtn = null;
        //    //    mylog4net.Error("", ex);
        //    //}
        //    //return returnMachineMtn;

        //}

        public ReturnMachineMtn GetMachineMtnbyID(int ID)
        {
            List <MachineMtn> lstMachineMtn    = null;
            MachineMtn        machineMtn       = null;
            ReturnMachineMtn  returnMachineMtn = new ReturnMachineMtn();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtn_SelectByID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = ID;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstMachineMtn = new List <MachineMtn>();
                                while (sqlDr.Read())
                                {
                                    machineMtn           = new MachineMtn();
                                    machineMtn.ID        = Convert.ToInt16(sqlDr["ID"].ToString());
                                    machineMtn.MachineID = sqlDr["MachineID"].ToString();
                                    //get MachineName.
                                    ReturnMachine returnMachine = (new MachineDB()).GetbyID(machineMtn.MachineID);
                                    if (returnMachine.Code == "00")
                                    {
                                        machineMtn.MachineName = returnMachine.lstMachine[0].MachineName;
                                    }
                                    //get OperatorName.
                                    int        _operatorID = 0;
                                    ReturnUser returnUser;
                                    if (Int32.TryParse(sqlDr["OperatorID"].ToString(), out _operatorID))
                                    {
                                        returnUser = (new UserDB()).GetbyID(_operatorID);
                                        if (returnUser.Code == "00")
                                        {
                                            machineMtn.OperatorName = returnUser.lstUser[0].UserName;
                                        }
                                    }
                                    machineMtn.Shift           = Convert.ToInt16(sqlDr["Shift"].ToString());
                                    machineMtn.MaintenanceDate = Convert.ToDateTime(sqlDr["MaintenanceDate"].ToString());
                                    if (!String.IsNullOrEmpty(sqlDr["FrequencyID"].ToString()))
                                    {
                                        machineMtn.FrequencyID = Convert.ToInt16(sqlDr["FrequencyID"].ToString());
                                    }
                                    machineMtn.Result         = sqlDr["Result"].ToString();
                                    machineMtn.ResultContents = sqlDr["ResultContents"].ToString();
                                    if (!String.IsNullOrEmpty(sqlDr["Month"].ToString()))
                                    {
                                        machineMtn.Month = Convert.ToInt16(sqlDr["Month"].ToString());
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["Year"].ToString()))
                                    {
                                        machineMtn.Year = Convert.ToInt16(sqlDr["Year"].ToString());
                                    }
                                    if (!String.IsNullOrEmpty(sqlDr["Week"].ToString()))
                                    {
                                        machineMtn.Week = Convert.ToInt16(sqlDr["Week"].ToString());
                                    }
                                    if (sqlDr["CheckerID"].ToString() != "")
                                    {
                                        machineMtn.CheckerID = Convert.ToInt16(sqlDr["CheckerID"].ToString());
                                        //get name.
                                        int        _CheckerID = 0;
                                        ReturnUser returnChecker;
                                        if (Int32.TryParse(sqlDr["CheckerID"].ToString(), out _operatorID))
                                        {
                                            returnChecker = (new UserDB()).GetbyID(_CheckerID);
                                            if (returnChecker.Code == "00")
                                            {
                                                machineMtn.CheckerName = returnChecker.lstUser[0].UserName;
                                            }
                                        }
                                    }
                                    if (sqlDr["CheckerResult"].ToString() != "")
                                    {
                                        machineMtn.CheckerResult = sqlDr["CheckerResult"].ToString();
                                    }
                                    lstMachineMtn.Add(machineMtn);
                                }
                                returnMachineMtn.Code          = "00";
                                returnMachineMtn.Message       = "Lấy dữ liệu thành công.";
                                returnMachineMtn.lstMachineMtn = lstMachineMtn;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnMachineMtn.Code          = "01";
                                returnMachineMtn.Message       = "Không tồn tại bản ghi nào.";
                                returnMachineMtn.Total         = 0;
                                returnMachineMtn.lstMachineMtn = null;
                                returnMachineMtn.UserID        = MyShareInfo.ID;
                                returnMachineMtn.UserName      = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtn.Code          = "99";
                returnMachineMtn.Message       = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtn.Total         = 0;
                returnMachineMtn.lstMachineMtn = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineMtn);
        }