Ejemplo n.º 1
0
        public ReturnMachineMtnDetail CountbyMachineMtnContentID(int machineMtnContentID)
        {
            //List<int> lstint = null;
            ReturnMachineMtnDetail returnMachineMtnDetail = new ReturnMachineMtnDetail();

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

                        using (SqlDataReader sqlDr = ConnectSQLCommon.ExecuteDataReader(cmd))
                        {
                            if (sqlDr.HasRows)
                            {
                                //lstint = new List<int>();
                                while (sqlDr.Read())
                                {
                                    returnMachineMtnDetail.Total = Convert.ToInt16(sqlDr[0].ToString());
                                }
                                returnMachineMtnDetail.Code                = "00";
                                returnMachineMtnDetail.Message             = "Lấy dữ liệu thành công.";
                                returnMachineMtnDetail.lstMachineMtnDetail = null;
                            }
                            else
                            {
                                returnMachineMtnDetail.Code                = "01";
                                returnMachineMtnDetail.Message             = "Không tồn tại bản ghi nào.";
                                returnMachineMtnDetail.Total               = 0;
                                returnMachineMtnDetail.lstMachineMtnDetail = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnDetail.Code                = "99";
                returnMachineMtnDetail.Message             = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnDetail.Total               = 0;
                returnMachineMtnDetail.lstMachineMtnDetail = null;
                mylog4net.Error("public ReturnMachineMtnDetail CountbyCondition(int machineMtnContentID) :", ex);
            }
            return(returnMachineMtnDetail);
        }
Ejemplo n.º 2
0
        public ReturnMachineMtnDetail Insert(MachineMtnDetail machineMtnDetail)
        {
            ReturnMachineMtnDetail returnMachineMtnDetail = new ReturnMachineMtnDetail();

            try
            {
                using (SqlConnection sqlConnection = ConnectSQLCommon.CreateAndOpenSqlConnection())
                {
                    using (SqlCommand cmd = new SqlCommand("", sqlConnection))
                    {
                        cmd.CommandText = "sp_tMachineMtnDetail_InsertUpdate";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value                  = machineMtnDetail.ID;
                        cmd.Parameters.Add(new SqlParameter("@MachineMtnID", SqlDbType.Int)).Value        = machineMtnDetail.MachineMtnID;
                        cmd.Parameters.Add(new SqlParameter("@MachineMtnContentID", SqlDbType.Int)).Value = machineMtnDetail.MachineMtnContentID;
                        cmd.Parameters.Add(new SqlParameter("@Result", SqlDbType.VarChar)).Value          = machineMtnDetail.Result;
                        cmd.Parameters.Add(new SqlParameter("@ResultContents", SqlDbType.NVarChar)).Value = machineMtnDetail.ResultContents;

                        cmd.Parameters.Add(new SqlParameter("@ContentMtn", SqlDbType.NVarChar)).Value  = machineMtnDetail.ContentMtn;
                        cmd.Parameters.Add(new SqlParameter("@ToolMtn", SqlDbType.NVarChar)).Value     = machineMtnDetail.ToolMtn;
                        cmd.Parameters.Add(new SqlParameter("@MethodMtn", SqlDbType.NVarChar)).Value   = machineMtnDetail.MethodMtn;
                        cmd.Parameters.Add(new SqlParameter("@Standard", SqlDbType.NVarChar)).Value    = machineMtnDetail.Standard;
                        cmd.Parameters.Add(new SqlParameter("@Min", SqlDbType.NVarChar)).Value         = machineMtnDetail.Min;
                        cmd.Parameters.Add(new SqlParameter("@Max", SqlDbType.NVarChar)).Value         = machineMtnDetail.Max;
                        cmd.Parameters.Add(new SqlParameter("@ActualValue", SqlDbType.NVarChar)).Value = machineMtnDetail.ActualValue;

                        cmd.ExecuteNonQuery();
                        returnMachineMtnDetail.Code    = "00";
                        returnMachineMtnDetail.Message = "Cập nhật dữ liệu thành công.";
                    }
                }
            }
            catch (Exception ex)
            {
                returnMachineMtnDetail.Code                = "99";
                returnMachineMtnDetail.Message             = "Lỗi xử lý dữ liệu: " + ex.ToString();
                returnMachineMtnDetail.Total               = 0;
                returnMachineMtnDetail.lstMachineMtnDetail = null;
                mylog4net.Error("", ex);
            }
            return(returnMachineMtnDetail);
        }