public ReturnProgramPdtCtrl Insert(ProgramPdtCtrl p)
        {
            ReturnProgramPdtCtrl returnProgramPdtCtrl = new ReturnProgramPdtCtrl();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProgramPdtCtrl_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value  = p.ProgramName;
                        cmd.Parameters.Add(new SqlParameter("@Part", SqlDbType.NVarChar)).Value        = String.IsNullOrEmpty(p.Part) ? "" : p.Part;
                        cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.NVarChar)).Value = p.ControlItem;
                        cmd.Parameters.Add(new SqlParameter("@ColumnName", SqlDbType.NVarChar)).Value  = String.IsNullOrEmpty(p.ColumnName) ? "" : p.ColumnName;
                        cmd.Parameters.Add(new SqlParameter("@LowerLimit", SqlDbType.NVarChar)).Value  = p.LowerLimit;
                        cmd.Parameters.Add(new SqlParameter("@Unit", SqlDbType.NVarChar)).Value        = String.IsNullOrEmpty(p.Unit) ? "" : p.Unit;
                        cmd.Parameters.Add(new SqlParameter("@UpperLimit", SqlDbType.NVarChar)).Value  = p.UpperLimit;
                        cmd.Parameters.Add(new SqlParameter("@OperatorID", SqlDbType.Int)).Value       = p.OperatorID;
                        cmd.Parameters.Add(new SqlParameter("@SpecDisplay", SqlDbType.NVarChar)).Value = String.IsNullOrEmpty(p.SpecDisplay) ? "" : p.SpecDisplay;

                        //int RETURN_CODE = Convert.ToInt32(cmd.Parameters["@RETURN_CODE"].Value);
                        cmd.ExecuteNonQuery();
                        returnProgramPdtCtrl.Code    = "00";
                        returnProgramPdtCtrl.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnProgramPdtCtrl.Code              = "99";
                returnProgramPdtCtrl.Message           = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProgramPdtCtrl.Total             = 0;
                returnProgramPdtCtrl.lstProgramPdtCtrl = null;
                mylog4net.Error("", ex);
            }
            return(returnProgramPdtCtrl);
        }
示例#2
0
        public ReturnMachine Insert(Machine machine)
        {
            ReturnMachine returnMachine = new ReturnMachine();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineList_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.VarChar)).Value      = machine.MachineID;
                        cmd.Parameters.Add(new SqlParameter("@MachineName", SqlDbType.NVarChar)).Value   = machine.MachineName;
                        cmd.Parameters.Add(new SqlParameter("@MachineNumber", SqlDbType.NVarChar)).Value = machine.MachineNumber;
                        cmd.Parameters.Add(new SqlParameter("@Area", SqlDbType.VarChar)).Value           = machine.Area;
                        cmd.Parameters.Add(new SqlParameter("@Section", SqlDbType.VarChar)).Value        = machine.Section == null ? "" : machine.Section;
                        cmd.Parameters.Add(new SqlParameter("@ReceiveDate", SqlDbType.DateTime)).Value   = machine.ReceiveDate;
                        cmd.Parameters.Add(new SqlParameter("@Maker", SqlDbType.VarChar)).Value          = machine.Maker == null ? "" : machine.Maker;
                        cmd.Parameters.Add(new SqlParameter("@SerialNumber", SqlDbType.VarChar)).Value   = machine.SerialNumber == null ? "" : machine.SerialNumber;
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value         = machine.LineID;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.Int)).Value      = machine.MachineTypeID;
                        cmd.ExecuteNonQuery();

                        returnMachine.Code    = "00";
                        returnMachine.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            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 ReturnToolCleaningContent Insert(ToolCleaningContent toolCleaningContent)
        {
            ReturnToolCleaningContent returnToolCleaningContent = new ReturnToolCleaningContent();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tToolCleaningContent_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ToolID", SqlDbType.VarChar)).Value          = toolCleaningContent.ToolID;
                        cmd.Parameters.Add(new SqlParameter("@LineUsing", SqlDbType.VarChar)).Value       = toolCleaningContent.LineUsing;
                        cmd.Parameters.Add(new SqlParameter("@Shift", SqlDbType.SmallInt)).Value          = toolCleaningContent.Shift;
                        cmd.Parameters.Add(new SqlParameter("@Result", SqlDbType.VarChar)).Value          = toolCleaningContent.Result;
                        cmd.Parameters.Add(new SqlParameter("@NGContents", SqlDbType.NVarChar)).Value     = toolCleaningContent.NGContents;
                        cmd.Parameters.Add(new SqlParameter("@RepairDate", SqlDbType.DateTime)).Value     = toolCleaningContent.RepairDate;
                        cmd.Parameters.Add(new SqlParameter("@RepairContents", SqlDbType.NVarChar)).Value = toolCleaningContent.RepairContents;
                        cmd.Parameters.Add(new SqlParameter("@RepairID", SqlDbType.VarChar)).Value        = toolCleaningContent.RepairID;
                        cmd.Parameters.Add(new SqlParameter("@CheckBy", SqlDbType.VarChar)).Value         = toolCleaningContent.CheckBy;
                        cmd.Parameters.Add(new SqlParameter("@ImageLink", SqlDbType.VarChar)).Value       = String.IsNullOrEmpty(toolCleaningContent.ImageLink) ? "" : toolCleaningContent.ImageLink;
                        cmd.ExecuteNonQuery();

                        returnToolCleaningContent.Code    = "00";
                        returnToolCleaningContent.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnToolCleaningContent.Code    = "99";
                returnToolCleaningContent.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnToolCleaningContent.Total   = 0;
                returnToolCleaningContent.LstToolCleaningContent = null;
                mylog4net.Error("", ex);
            }
            return(returnToolCleaningContent);
        }
示例#4
0
        public ReturnFPB Insert(FPB FPB)
        {
            ReturnFPB returnFPB = new ReturnFPB();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_FPB_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = FPB.ID;
                        cmd.Parameters.Add(new SqlParameter("@IDFPBCheckingItem", SqlDbType.Int)).Value  = FPB.IDFPBCheckingItem;
                        cmd.Parameters.Add(new SqlParameter("@FPBDate", SqlDbType.DateTime)).Value       = FPB.FPBDate;
                        cmd.Parameters.Add(new SqlParameter("@IndicationNo", SqlDbType.VarChar)).Value   = FPB.IndicationNo;
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.VarChar)).Value         = FPB.UserID;
                        cmd.Parameters.Add(new SqlParameter("@SeqNo", SqlDbType.VarChar)).Value          = FPB.SeqNo;
                        cmd.Parameters.Add(new SqlParameter("@BlockID", SqlDbType.VarChar)).Value        = FPB.BlockID;
                        cmd.Parameters.Add(new SqlParameter("@Result", SqlDbType.VarChar)).Value         = FPB.Result;
                        cmd.Parameters.Add(new SqlParameter("@ResultContent", SqlDbType.NVarChar)).Value = FPB.ResultContent;

                        cmd.ExecuteNonQuery();

                        returnFPB.Code    = "00";
                        returnFPB.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPB.Code    = "99";
                returnFPB.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPB.Total   = 0;
                returnFPB.LstFPB  = null;
                mylog4net.Error("", ex);
            }
            return(returnFPB);
        }
        public ReturnMachineMtnContentList ImportExcel(Import_MachineMtnType_ContentList import_aMachineMtnType_ContentList)
        {
            ReturnMachineMtnContentList returnMachineTypeMtnContentList = new ReturnMachineMtnContentList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnContentList_ImportExcel";
                        cmd.CommandType = CommandType.StoredProcedure;
                        //cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = machineMtnContentList.ID;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.Int)).Value    = import_aMachineMtnType_ContentList.MachineTypeID;
                        cmd.Parameters.Add(new SqlParameter("@MachinePart", SqlDbType.NVarChar)).Value = import_aMachineMtnType_ContentList.MachinePart.Trim();
                        cmd.Parameters.Add(new SqlParameter("@ContentMtn", SqlDbType.NVarChar)).Value  = import_aMachineMtnType_ContentList.ContentMtn.Trim();
                        cmd.Parameters.Add(new SqlParameter("@ToolMtn", SqlDbType.NVarChar)).Value     = import_aMachineMtnType_ContentList.ToolMtn.Trim();
                        cmd.Parameters.Add(new SqlParameter("@MethodMtn", SqlDbType.NVarChar)).Value   = import_aMachineMtnType_ContentList.MethodMtn.Trim();
                        cmd.Parameters.Add(new SqlParameter("@Standard", SqlDbType.NVarChar)).Value    = import_aMachineMtnType_ContentList.Standard.Trim();
                        cmd.Parameters.Add(new SqlParameter("@Min", SqlDbType.NVarChar)).Value         = import_aMachineMtnType_ContentList.Min.Trim();
                        cmd.Parameters.Add(new SqlParameter("@Max", SqlDbType.NVarChar)).Value         = import_aMachineMtnType_ContentList.Max.Trim();
                        cmd.Parameters.Add(new SqlParameter("@FrequencyID", SqlDbType.SmallInt)).Value = import_aMachineMtnType_ContentList.FrequencyID;
                        int x = cmd.ExecuteNonQuery();

                        returnMachineTypeMtnContentList.Code    = "00";
                        returnMachineTypeMtnContentList.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineTypeMtnContentList.Code    = "99";
                returnMachineTypeMtnContentList.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineTypeMtnContentList.Total   = 0;
                returnMachineTypeMtnContentList.lstMachineMtnContentList = null;
                mylog4net.Error("public ReturnMachineMtnContentList ImportExcel(Import_MachineMtnType_ContentList import_aMachineMtnType_ContentList): ", ex);
            }
            return(returnMachineTypeMtnContentList);
        }
        public ReturnConditionSetting Insert(ConditionSetting conditionSetting)
        {
            ReturnConditionSetting returnConditionSetting = new ReturnConditionSetting();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProductionControlList_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value                = conditionSetting.ID;
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value        = conditionSetting.LineID;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.VarChar)).Value = conditionSetting.MachineTypeID;
                        cmd.Parameters.Add(new SqlParameter("@PatternCode", SqlDbType.VarChar)).Value   = conditionSetting.PatternCode;
                        cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.NVarChar)).Value  = conditionSetting.ControlItem;
                        cmd.Parameters.Add(new SqlParameter("@SpecDisplay", SqlDbType.NVarChar)).Value  = conditionSetting.SpecDisplay;
                        cmd.Parameters.Add(new SqlParameter("@Unit", SqlDbType.NVarChar)).Value         = conditionSetting.Unit;
                        cmd.Parameters.Add(new SqlParameter("@LowerLimit", SqlDbType.Float)).Value      = conditionSetting.LowerLimit;
                        cmd.Parameters.Add(new SqlParameter("@UpperLimit", SqlDbType.Float)).Value      = conditionSetting.UpperLimit;
                        cmd.ExecuteNonQuery();

                        returnConditionSetting.Code    = "00";
                        returnConditionSetting.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            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);
        }
示例#7
0
        public ReturnProductionList Insert(ProductionList productionList)
        {
            ReturnProductionList returnProductionList = new ReturnProductionList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tProductionList_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@IndicatorID", SqlDbType.VarChar)).Value = productionList.IndicatorID;
                        cmd.Parameters.Add(new SqlParameter("@ItemName", SqlDbType.VarChar)).Value    = productionList.ItemName;
                        cmd.Parameters.Add(new SqlParameter("@ItemCode", SqlDbType.VarChar)).Value    = productionList.ItemCode;
                        cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value = productionList.ProgramName;
                        cmd.Parameters.Add(new SqlParameter("@BatchNo", SqlDbType.VarChar)).Value     = productionList.BatchNo;
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value      = productionList.LineID;
                        cmd.Parameters.Add(new SqlParameter("@MachineTypeID", SqlDbType.Int)).Value   = productionList.MachineTypeID;
                        cmd.Parameters.Add(new SqlParameter("@PatternCode", SqlDbType.VarChar)).Value = productionList.PatternCode;
                        cmd.ExecuteNonQuery();

                        returnProductionList.Code    = "00";
                        returnProductionList.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnProductionList.Code              = "99";
                returnProductionList.Message           = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProductionList.Total             = 0;
                returnProductionList.lstProductionList = null;
                mylog4net.Error("", ex);
            }
            return(returnProductionList);
        }
示例#8
0
        public ReturnToolIQC Insert(ToolIQC _toolIQC)
        {
            ReturnToolIQC returnToolIQC = new ReturnToolIQC();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tToolIQC_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value               = _toolIQC.ID;
                        cmd.Parameters.Add(new SqlParameter("@ToolTypeID", SqlDbType.Int)).Value       = _toolIQC.ToolTypeID;
                        cmd.Parameters.Add(new SqlParameter("@PrefixToolID", SqlDbType.VarChar)).Value = _toolIQC.PrefixToolID;
                        cmd.Parameters.Add(new SqlParameter("@FromToolID", SqlDbType.VarChar)).Value   = _toolIQC.FromToolID;
                        cmd.Parameters.Add(new SqlParameter("@ToToolID", SqlDbType.VarChar)).Value     = _toolIQC.ToToolID;
                        cmd.Parameters.Add(new SqlParameter("@FileUrl", SqlDbType.NVarChar)).Value     = _toolIQC.FileUrl;
                        cmd.Parameters.Add(new SqlParameter("@FactoryID", SqlDbType.VarChar)).Value    = _toolIQC.FactoryID;
                        cmd.Parameters.Add(new SqlParameter("@OperatorID", SqlDbType.VarChar)).Value   = _toolIQC.OperatorID;
                        cmd.ExecuteNonQuery();
                        returnToolIQC.Code    = "00";
                        returnToolIQC.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnToolIQC.Code       = "99";
                returnToolIQC.Message    = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnToolIQC.Total      = 0;
                returnToolIQC.lstToolIQC = null;
                mylog4net.Error("", ex);
            }
            return(returnToolIQC);
        }
        public ReturnProgramPdtCtrlHistory DeleteByKey(ProgramPdtCtrlHistory p)
        {
            ReturnProgramPdtCtrlHistory returnProgramPdtCtrlHistory = new ReturnProgramPdtCtrlHistory();

            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_tProgramPdtCtrlHistory_DeleteByKey";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ProgramName", SqlDbType.VarChar)).Value = p.ProgramName;
                        cmd.Parameters.Add(new SqlParameter("@Parameter", SqlDbType.VarChar)).Value   = p.Parameter;

                        cmd.Parameters.Add(new SqlParameter("@ControlItem", SqlDbType.VarChar)).Value = p.ControlItem;

                        //cmd.Parameters.Add("@RETURN_CODE", SqlDbType.Int).Direction = ParameterDirection.Output;
                        //int RETURN_CODE = Convert.ToInt32(cmd.Parameters["@RETURN_CODE"].Value);
                        cmd.ExecuteNonQuery();
                        returnProgramPdtCtrlHistory.Code    = "00";
                        returnProgramPdtCtrlHistory.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            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);
        }
示例#10
0
        public string GetToolTypeNamebyID(string ToolTypeID)
        {
            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tToolTypeList_GetToolTypeNamebyID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ToolTypeID", SqlDbType.VarChar)).Value = ToolTypeID;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                while (sqlDr.Read())
                                {
                                    return(sqlDr[0].ToString());
                                }
                            }
                            else
                            {
                                return("");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return("");
            }
            return("");
        }
示例#11
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);
        }
示例#12
0
        public ReturnMachineMtn Insert(MachineMtn machineMtn)
        {
            ReturnMachineMtn returnMachineMtn = new ReturnMachineMtn();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtn_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value             = machineMtn.ID;
                        cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.VarChar)).Value  = machineMtn.MachineID;
                        cmd.Parameters.Add(new SqlParameter("@OperatorID", SqlDbType.VarChar)).Value = machineMtn.OperatorID;
                        if (machineMtn.Shift != 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Shift", SqlDbType.SmallInt)).Value = machineMtn.Shift;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Shift", SqlDbType.SmallInt)).Value = DBNull.Value;
                        }
                        cmd.Parameters.Add(new SqlParameter("@MaintenanceDate", SqlDbType.DateTime)).Value = machineMtn.MaintenanceDate;
                        cmd.Parameters.Add(new SqlParameter("@FrequencyID", SqlDbType.Int)).Value          = machineMtn.FrequencyID;
                        cmd.Parameters.Add(new SqlParameter("@Result", SqlDbType.VarChar)).Value           = machineMtn.Result;
                        cmd.Parameters.Add(new SqlParameter("@ResultContents", SqlDbType.NVarChar)).Value  = "";
                        if (machineMtn.Week != 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Week", SqlDbType.Int)).Value = machineMtn.Week;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Week", SqlDbType.Int)).Value = DBNull.Value;
                        }

                        if (machineMtn.Month != 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Month", SqlDbType.SmallInt)).Value = machineMtn.Month;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Month", SqlDbType.SmallInt)).Value = DBNull.Value;
                        }
                        if (machineMtn.Year != 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Year", SqlDbType.Int)).Value = machineMtn.Year;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Year", SqlDbType.Int)).Value = DBNull.Value;
                        }

                        cmd.Parameters.Add(new SqlParameter("@CheckerID", SqlDbType.Int)).Value         = machineMtn.CheckerID;
                        cmd.Parameters.Add(new SqlParameter("@CheckerResult", SqlDbType.VarChar)).Value = machineMtn.CheckerResult;
                        cmd.Parameters.Add("@LastID", SqlDbType.Int).Direction = ParameterDirection.Output;
                        cmd.ExecuteNonQuery();

                        returnMachineMtn.Code    = "00";
                        returnMachineMtn.Message = "Cập nhật dữ liệu thành công.";
                        //if (returnMachineMtn.Code == "00")
                        //    returnMachineMtn.LastID = Convert.ToInt32(cmd.Parameters["@LastID"].Value);
                        if (returnMachineMtn.Code == "00")
                        {
                            returnMachineMtn.LastID = Convert.ToInt32(cmd.Parameters["@LastID"].Value);
                        }
                    }
                }
            }
            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 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);
        }
示例#14
0
        public ReturnFPB GetbyID(string ID)
        {
            List <FPB> lstFPB    = null;
            FPB        FPB       = null;
            ReturnFPB  returnFPB = new ReturnFPB();

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

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstFPB = new List <FPB>();
                                while (sqlDr.Read())
                                {
                                    FPB    = new FPB();
                                    FPB.ID = int.Parse(sqlDr["ID"].ToString());
                                    FPB.IDFPBCheckingItem = int.Parse(sqlDr["IDFPBCheckingItem"].ToString());
                                    FPB.FPBDate           = DateTime.Parse(sqlDr["FPBDate"].ToString());
                                    FPB.IndicationNo      = sqlDr["IndicationNo"].ToString();
                                    FPB.UserID            = sqlDr["UserID"].ToString();
                                    FPB.SeqNo             = sqlDr["SeqNo"].ToString();
                                    FPB.BlockID           = sqlDr["BlockID"].ToString();
                                    FPB.Result            = sqlDr["Result"].ToString();
                                    FPB.ResultContent     = sqlDr["ResultContent"].ToString();
                                    lstFPB.Add(FPB);
                                }
                                returnFPB.Code    = "00";
                                returnFPB.Message = "Lấy dữ liệu thành công.";
                                returnFPB.LstFPB  = lstFPB;
                            }
                            else
                            {
                                returnFPB.Code    = "01";
                                returnFPB.Message = "Không tồn tại bản ghi nào.";
                                returnFPB.Total   = 0;
                                returnFPB.LstFPB  = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPB.Code    = "99";
                returnFPB.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPB.Total   = 0;
                returnFPB.LstFPB  = null;
                mylog4net.Error("", ex);
            }
            return(returnFPB);
        }
        public ReturnProductionControl SearchProductionControl_UsingDataTables(SearchProductionControl searchProductionControl, int pageNumber, int pageSize)
        {
            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.Parameters.AddWithValue("@MachineID", searchProductionControl.MachineID);
                        cmd.Parameters.AddWithValue("@IndicationID", searchProductionControl.IndicationID);
                        cmd.Parameters.AddWithValue("@ProgramName", searchProductionControl.ProgramName);
                        cmd.Parameters.AddWithValue("@Result", searchProductionControl.Result);
                        if (searchProductionControl.FromDate != DateTime.MinValue)
                        {
                            cmd.Parameters.AddWithValue("@FromDate", searchProductionControl.FromDate);
                        }
                        if (searchProductionControl.ToDate != DateTime.MinValue)
                        {
                            cmd.Parameters.AddWithValue("@ToDate", searchProductionControl.ToDate);
                        }

                        //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;

                        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;
                            }
                            else
                            {
                                returnProductionControl.Code    = "01";
                                returnProductionControl.Message = "Không tồn tại bản ghi nào.";
                                returnProductionControl.Total   = 0;
                                returnProductionControl.lstProductionControl = null;
                            }
                        }
                        //paging.
                        if (returnProductionControl.Code == "00")
                        {
                            returnProductionControl.Total = Convert.ToInt32(cmd.Parameters["@totalRow"].Value);
                        }
                    }
                }
            }
            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);
        }
示例#16
0
        public ReturnToolList SelectByCondition(string where)
        {
            List <ToolList> lstToolList    = null;
            ToolList        toolList       = null;
            ReturnToolList  returnToolList = new ReturnToolList();

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

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstToolList = new List <ToolList>();
                                while (sqlDr.Read())
                                {
                                    toolList               = new ToolList();
                                    toolList.ToolID        = sqlDr["ToolID"].ToString();
                                    toolList.UserID        = sqlDr["UserID"].ToString();
                                    toolList.UserName      = sqlDr["UserName"].ToString();
                                    toolList.ToolType      = sqlDr["ToolType"].ToString();
                                    toolList.ItemCode      = sqlDr["ItemCode"].ToString();
                                    toolList.Maker         = sqlDr["Maker"].ToString();
                                    toolList.Specification = sqlDr["Specification"].ToString();
                                    toolList.ReceiveDate   = DateTime.Parse(sqlDr["ReceiveDate"].ToString());
                                    toolList.StartUsing    = DateTime.Parse(sqlDr["StartUsing"].ToString());
                                    //toolList.ReceiveDate = sqlDr["ReceiveDate"].ToString();
                                    //toolList.StartUsing = sqlDr["StartUsing"].ToString();

                                    toolList.LifeTime   = sqlDr["LifeTime"].ToString();
                                    toolList.ExpireDate = DateTime.Parse(sqlDr["ExpireDate"].ToString());
                                    //toolList.ExpireDate = sqlDr["ExpireDate"].ToString();
                                    toolList.LineID      = sqlDr["LineID"].ToString();
                                    toolList.Status      = sqlDr["Status"].ToString();
                                    toolList.Remark      = sqlDr["Remark"].ToString();
                                    toolList.ImageUrl    = sqlDr["ImageUrl"].ToString();
                                    toolList.CreatedDate = DateTime.Parse(sqlDr["CreatedDate"].ToString());
                                    toolList.isActive    = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstToolList.Add(toolList);
                                }
                                returnToolList.Code    = "00";
                                returnToolList.Message = "Lấy dữ liệu thành công.";
                                //_ReturnToolList.Total = Convert.ToInt32(cmd.Parameters["P_TOTAL"].Value.ToString());
                                returnToolList.lstToolList = lstToolList;
                                returnToolList.UserID      = MyShareInfo.ID;
                                returnToolList.UserName    = MyShareInfo.UserName;
                                //}
                            }
                            else
                            {
                                returnToolList.Code        = "01";
                                returnToolList.Message     = "Không tồn tại bản ghi nào.";
                                returnToolList.Total       = 0;
                                returnToolList.lstToolList = null;
                                returnToolList.UserID      = MyShareInfo.ID;
                                returnToolList.UserName    = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnToolList.Code        = "99";
                returnToolList.Message     = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnToolList.Total       = 0;
                returnToolList.lstToolList = null;
            }
            return(returnToolList);
        }
        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);
        }
        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);
        }
示例#19
0
        public ReturnProductionList GetbyID(string ID)
        {
            List <ProductionList> lstProductionList    = null;
            ProductionList        productionList       = null;
            ReturnProductionList  returnProductionList = new ReturnProductionList();

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

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd, sqlConnection))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstProductionList = new List <ProductionList>();
                                while (sqlDr.Read())
                                {
                                    productionList                 = new ProductionList();
                                    productionList.IndicatorID     = sqlDr["IndicatorID"].ToString();
                                    productionList.ItemName        = sqlDr["ItemName"].ToString();
                                    productionList.ItemCode        = sqlDr["ItemCode"].ToString();
                                    productionList.BatchNo         = sqlDr["BatchNo"].ToString();
                                    productionList.ProgramName     = sqlDr["ProgramName"].ToString();
                                    productionList.LineID          = sqlDr["LineID"].ToString();
                                    productionList.MachineTypeID   = Convert.ToInt32(sqlDr["MachineTypeID"].ToString());
                                    productionList.PatternCode     = sqlDr["PatternCode"].ToString();
                                    productionList.MachineTypeName = sqlDr["TypeName"].ToString();
                                    lstProductionList.Add(productionList);
                                }
                                returnProductionList.Code              = "00";
                                returnProductionList.Message           = "Lấy dữ liệu thành công.";
                                returnProductionList.lstProductionList = lstProductionList;
                                returnProductionList.Total             = lstProductionList.Count;
                                //}
                            }
                            else
                            {
                                returnProductionList.Code              = "01";
                                returnProductionList.Message           = "Không tồn tại bản ghi nào.";
                                returnProductionList.Total             = 0;
                                returnProductionList.lstProductionList = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnProductionList.Code              = "99";
                returnProductionList.Message           = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnProductionList.Total             = 0;
                returnProductionList.lstProductionList = null;
                mylog4net.Error("", ex);
            }
            return(returnProductionList);
        }
示例#20
0
        public ReturnUser GetbyID(int ID)
        {
            List <User> lstUser    = null;
            User        user       = null;
            ReturnUser  returnUser = new ReturnUser();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        //cmd.Connection = _sqlConnection;
                        cmd.CommandText = "sp_tUser_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)
                            {
                                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);
        }
示例#21
0
        public ReturnUser CheckPermission_ByUserNameAndPassword(string userName, string password, string permission)
        {
            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_CheckPermission";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar)).Value    = userName;
                        cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar)).Value    = password;
                        cmd.Parameters.Add(new SqlParameter("@Permission", SqlDbType.NVarChar)).Value = permission;
                        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);
        }
示例#22
0
        public ReturnMachineMtnContentDetail SelectByMachineMtnID(int MachineMtnID)
        {
            List <MachineMtnContentDetail> lstMachineMtnContentDetail    = null;
            MachineMtnContentDetail        machineMtnContentDetail       = null;
            ReturnMachineMtnContentDetail  returnMachineMtnContentDetail = new ReturnMachineMtnContentDetail();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnDetail_SelectByMachineMtnID";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineMtnID", SqlDbType.Int)).Value = MachineMtnID;
                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMachineMtnContentDetail = new List <MachineMtnContentDetail>();
                                while (sqlDr.Read())
                                {
                                    machineMtnContentDetail                     = new MachineMtnContentDetail();
                                    machineMtnContentDetail.ID                  = Convert.ToInt16(sqlDr["ID"].ToString());
                                    machineMtnContentDetail.MachineMtnID        = Convert.ToInt16(sqlDr["MachineMtnID"].ToString());
                                    machineMtnContentDetail.MachineMtnContentID = Convert.ToInt16(sqlDr["MachineMtnContentID"].ToString());
                                    machineMtnContentDetail.Result              = sqlDr["Result"].ToString();
                                    machineMtnContentDetail.ResultContents      = sqlDr["ResultContents"].ToString();
                                    machineMtnContentDetail.MachinePart         = sqlDr["MachinePartID"].ToString();
                                    machineMtnContentDetail.ContentMtn          = sqlDr["ContentMtn"].ToString();
                                    machineMtnContentDetail.ToolMtn             = sqlDr["ToolMtn"].ToString();
                                    machineMtnContentDetail.MethodMtn           = sqlDr["MethodMtn"].ToString();
                                    machineMtnContentDetail.Standard            = sqlDr["Standard"].ToString();
                                    machineMtnContentDetail.MachinePartName     = sqlDr["Name"].ToString();
                                    machineMtnContentDetail.Min                 = sqlDr["Min"].ToString();
                                    machineMtnContentDetail.Max                 = sqlDr["Max"].ToString();
                                    machineMtnContentDetail.ActualValue         = sqlDr["ActualValue"].ToString();
                                    lstMachineMtnContentDetail.Add(machineMtnContentDetail);
                                }
                                returnMachineMtnContentDetail.Code    = "00";
                                returnMachineMtnContentDetail.Message = "Lấy dữ liệu thành công.";
                                returnMachineMtnContentDetail.lstMachineMtnContentDetail = lstMachineMtnContentDetail;
                            }
                            else
                            {
                                returnMachineMtnContentDetail.Code    = "01";
                                returnMachineMtnContentDetail.Message = "Không tồn tại bản ghi nào.";
                                returnMachineMtnContentDetail.Total   = 0;
                                returnMachineMtnContentDetail.lstMachineMtnContentDetail = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnContentDetail.Code    = "99";
                returnMachineMtnContentDetail.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnContentDetail.Total   = 0;
                returnMachineMtnContentDetail.lstMachineMtnContentDetail = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineMtnContentDetail);
        }
示例#23
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);
        }
示例#24
0
        public ReturnMenu SelectTempSorted()
        {
            List <Menu> lstMenu    = null;
            Menu        menu       = null;
            ReturnMenu  returnMenu = new ReturnMenu();

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

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            //if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            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();
                                    if (menu.isActive == 1)
                                    {
                                        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);
        }
        public ReturnFPBCheckingItem GetFPBCheckingItemName(string MachineID)
        {
            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_GetFPBCheckingItemName";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@MachineID", SqlDbType.VarChar)).Value = MachineID;

                        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());

                                    lstFPBCheckingItem.Add(FPBCheckingItem);
                                }
                                returnFPBCheckingItem.Code               = "00";
                                returnFPBCheckingItem.Message            = "Lấy dữ liệu thành công.";
                                returnFPBCheckingItem.LstFPBCheckingItem = lstFPBCheckingItem;
                                returnFPBCheckingItem.UserID             = MyShareInfo.ID;
                                returnFPBCheckingItem.UserName           = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnFPBCheckingItem.Code               = "01";
                                returnFPBCheckingItem.Message            = "Không tồn tại bản ghi nào.";
                                returnFPBCheckingItem.Total              = 0;
                                returnFPBCheckingItem.LstFPBCheckingItem = null;
                                returnFPBCheckingItem.UserID             = MyShareInfo.ID;
                                returnFPBCheckingItem.UserName           = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            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);
        }
示例#26
0
        public ReturnMenuRole GetMenusByUserID(User user)
        {
            List <MenuRole> lstMenu    = null;
            MenuRole        menuRole   = null;
            ReturnMenuRole  returnMenu = new ReturnMenuRole();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "tMenu_listMenu_ByOrder_WithUserID";
                        cmd.Parameters.Add(new SqlParameter("@isReturnAllMenu", SqlDbType.Int)).Value = 0; // get  menu item corresponding to UserID.
                        cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Int)).Value          = user.ID;
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                lstMenu = new List <MenuRole>();
                                while (sqlDr.Read())
                                {
                                    menuRole              = new MenuRole();
                                    menuRole.ID           = int.Parse(sqlDr["ID"].ToString());
                                    menuRole.MenuName     = sqlDr["MenuName"].ToString();
                                    menuRole.DisplayName  = sqlDr["DisplayName"].ToString();
                                    menuRole.ParentMenuID = int.Parse(sqlDr["ParentMenuID"].ToString());
                                    menuRole.isActive     = int.Parse(sqlDr["isActive"].ToString());
                                    menuRole.UrlLink      = sqlDr["UrlLink"].ToString();
                                    menuRole.Permission   = sqlDr["Permission"].ToString();
                                    if (menuRole.isActive == 1)
                                    {
                                        lstMenu.Add(menuRole);
                                    }
                                }
                                returnMenu.Code        = "00";
                                returnMenu.Message     = "Lấy dữ liệu thành công.";
                                returnMenu.lstMenuRole = lstMenu;
                            }
                            else
                            {
                                returnMenu.Code        = "01";
                                returnMenu.Message     = "Không tồn tại bản ghi nào.";
                                returnMenu.Total       = 0;
                                returnMenu.lstMenuRole = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMenu.Code        = "99";
                returnMenu.Message     = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMenu.Total       = 0;
                returnMenu.lstMenuRole = null;
                mylog4net.Error("public ReturnMenuRole GetMenusByUserID(User user) ", ex);
            }
            return(returnMenu);
        }
示例#27
0
        public ReturnToolList ListAll()
        {
            List <ToolList> lstToolList    = null;
            ToolList        toolList       = null;
            ReturnToolList  returnToolList = new ReturnToolList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tToolList_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)
                            {
                                lstToolList = new List <ToolList>();
                                while (sqlDr.Read())
                                {
                                    toolList        = new ToolList();
                                    toolList.ToolID = sqlDr["ToolID"].ToString();
                                    toolList.UserID = sqlDr["UserID"].ToString();
                                    if (!String.IsNullOrEmpty(toolList.UserID))
                                    {
                                        toolList.UserName = (new UserDB()).getUserNameByID(Convert.ToInt16(toolList.UserID));
                                    }
                                    else
                                    {
                                        toolList.UserName = "";
                                    }
                                    toolList.ToolType = sqlDr["ToolType"].ToString();
                                    if (!String.IsNullOrEmpty(toolList.ToolType))
                                    {
                                        toolList.ToolTypeName = (new ToolTypeListDB()).GetToolTypeNamebyID(toolList.ToolType);
                                    }
                                    else
                                    {
                                        toolList.ToolTypeName = "";
                                    }

                                    toolList.ItemCode      = sqlDr["ItemCode"].ToString();
                                    toolList.Maker         = sqlDr["Maker"].ToString();
                                    toolList.Specification = sqlDr["Specification"].ToString();
                                    toolList.ReceiveDate   = DateTime.Parse(sqlDr["ReceiveDate"].ToString());
                                    toolList.StartUsing    = DateTime.Parse(sqlDr["StartUsing"].ToString());
                                    //toolList.ReceiveDate = sqlDr["ReceiveDate"].ToString();
                                    //toolList.StartUsing = sqlDr["StartUsing"].ToString();

                                    toolList.LifeTime   = sqlDr["LifeTime"].ToString();
                                    toolList.ExpireDate = DateTime.Parse(sqlDr["ExpireDate"].ToString());
                                    //toolList.ExpireDate = sqlDr["ExpireDate"].ToString();
                                    toolList.LineID      = sqlDr["LineID"].ToString();
                                    toolList.Status      = sqlDr["Status"].ToString();
                                    toolList.Remark      = sqlDr["Remark"].ToString();
                                    toolList.ImageUrl    = sqlDr["ImageUrl"].ToString();
                                    toolList.CreatedDate = DateTime.Parse(sqlDr["CreatedDate"].ToString());
                                    toolList.isActive    = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

                                    lstToolList.Add(toolList);
                                }
                                returnToolList.Code        = "00";
                                returnToolList.Message     = "Lấy dữ liệu thành công.";
                                returnToolList.lstToolList = lstToolList;
                                returnToolList.UserID      = MyShareInfo.ID;
                                returnToolList.UserName    = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnToolList.Code        = "01";
                                returnToolList.Message     = "Không tồn tại bản ghi nào.";
                                returnToolList.Total       = 0;
                                returnToolList.lstToolList = null;
                                returnToolList.UserID      = MyShareInfo.ID;
                                returnToolList.UserName    = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnToolList.Code        = "99";
                returnToolList.Message     = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnToolList.Total       = 0;
                returnToolList.lstToolList = null;
            }
            return(returnToolList);
        }
示例#28
0
        public ReturnFPB ListAll()
        {
            List <FPB> lstFPB    = null;
            FPB        FPB       = null;
            ReturnFPB  returnFPB = new ReturnFPB();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_FPB_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)
                            {
                                lstFPB = new List <FPB>();
                                while (sqlDr.Read())
                                {
                                    FPB    = new FPB();
                                    FPB.ID = int.Parse(sqlDr["ID"].ToString());
                                    FPB.IDFPBCheckingItem = int.Parse(sqlDr["IDFPBCheckingItem"].ToString());
                                    FPB.FPBDate           = DateTime.Parse(sqlDr["FPBDate"].ToString());
                                    FPB.IndicationNo      = sqlDr["IndicationNo"].ToString();
                                    FPB.UserID            = sqlDr["UserID"].ToString();
                                    FPB.SeqNo             = sqlDr["SeqNo"].ToString();
                                    FPB.BlockID           = sqlDr["BlockID"].ToString();
                                    FPB.Result            = sqlDr["Result"].ToString();
                                    FPB.ResultContent     = sqlDr["ResultContent"].ToString();

                                    lstFPB.Add(FPB);
                                }
                                returnFPB.Code     = "00";
                                returnFPB.Message  = "Lấy dữ liệu thành công.";
                                returnFPB.LstFPB   = lstFPB;
                                returnFPB.UserID   = MyShareInfo.ID;
                                returnFPB.UserName = MyShareInfo.UserName;
                            }
                            else
                            {
                                returnFPB.Code     = "01";
                                returnFPB.Message  = "Không tồn tại bản ghi nào.";
                                returnFPB.Total    = 0;
                                returnFPB.LstFPB   = null;
                                returnFPB.UserID   = MyShareInfo.ID;
                                returnFPB.UserName = MyShareInfo.UserName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnFPB.Code    = "99";
                returnFPB.Message = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnFPB.Total   = 0;
                returnFPB.LstFPB  = null;
                mylog4net.Error("", ex);
            }
            return(returnFPB);
        }
        //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);
        }
示例#30
0
        public ReturnToolList SearchTools(ReturnToolList searchToolLists, int pageSize)
        {
            List <ToolList> lstToolList    = null;
            ToolList        toolList       = null;
            ReturnToolList  returnToolList = new ReturnToolList();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tToolList_SearchTools";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ToolID", SqlDbType.VarChar)).Value   = string.Format("%{0}%", searchToolLists.aToolList.ToolID);
                        cmd.Parameters.Add(new SqlParameter("@ItemCode", SqlDbType.VarChar)).Value = string.Format("%{0}%", searchToolLists.aToolList.ItemCode);
                        cmd.Parameters.Add(new SqlParameter("@Maker", SqlDbType.VarChar)).Value    = string.Format("%{0}%", searchToolLists.aToolList.Maker);
                        if (searchToolLists.aToolList.ReceiveDate == DateTime.MinValue)
                        {
                            cmd.Parameters.Add(new SqlParameter("@ReceiveDate", SqlDbType.DateTime)).Value = DBNull.Value;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@ReceiveDate", SqlDbType.DateTime)).Value = searchToolLists.aToolList.ReceiveDate;
                        }
                        if (searchToolLists.aToolList.StartUsing == DateTime.MinValue)
                        {
                            cmd.Parameters.Add(new SqlParameter("@StartUsing", SqlDbType.DateTime)).Value = DBNull.Value;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@StartUsing", SqlDbType.DateTime)).Value = searchToolLists.aToolList.StartUsing;
                        }
                        if (searchToolLists.aToolList.ExpireDate == DateTime.MinValue)
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExpireDate", SqlDbType.DateTime)).Value = DBNull.Value;
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExpireDate", SqlDbType.DateTime)).Value = searchToolLists.aToolList.ExpireDate;
                        }
                        cmd.Parameters.Add(new SqlParameter("@LineID", SqlDbType.VarChar)).Value = string.Format("%{0}%", searchToolLists.aToolList.LineID);
                        cmd.Parameters.Add(new SqlParameter("@pageNumber", SqlDbType.Int)).Value = searchToolLists.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 (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                            //{
                            if (sqlDr.HasRows)
                            {
                                lstToolList = new List <ToolList>();
                                while (sqlDr.Read())
                                {
                                    toolList          = new ToolList();
                                    toolList.ToolID   = sqlDr["ToolID"].ToString();
                                    toolList.UserID   = sqlDr["UserID"].ToString();
                                    toolList.UserName = sqlDr["UserName"].ToString();
                                    toolList.ToolType = sqlDr["ToolType"].ToString();
                                    if (!String.IsNullOrEmpty(toolList.ToolType))
                                    {
                                        toolList.ToolTypeName = (new ToolTypeListDB()).GetToolTypeNamebyID(toolList.ToolType);
                                    }
                                    else
                                    {
                                        toolList.ToolTypeName = "";
                                    }
                                    toolList.ItemCode      = sqlDr["ItemCode"].ToString();
                                    toolList.Maker         = sqlDr["Maker"].ToString();
                                    toolList.Specification = sqlDr["Specification"].ToString();
                                    toolList.ReceiveDate   = DateTime.Parse(sqlDr["ReceiveDate"].ToString());
                                    toolList.StartUsing    = DateTime.Parse(sqlDr["StartUsing"].ToString());
                                    toolList.LifeTime      = sqlDr["LifeTime"].ToString();
                                    toolList.ExpireDate    = DateTime.Parse(sqlDr["ExpireDate"].ToString());
                                    toolList.LineID        = sqlDr["LineID"].ToString();
                                    toolList.Status        = sqlDr["Status"].ToString();
                                    toolList.Remark        = sqlDr["Remark"].ToString();
                                    toolList.ImageUrl      = sqlDr["ImageUrl"].ToString();
                                    toolList.CreatedDate   = DateTime.Parse(sqlDr["CreatedDate"].ToString());
                                    toolList.isActive      = SMCommon.ConvertToBoolean(sqlDr["isActive"].ToString());

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