Пример #1
0
        public static List <mg_sys_log> getTorqueAndAngleInfo1(string fl_id, string st_no, string part_no)
        {
            List <mg_sys_log>   result     = new List <mg_sys_log>();
            StringBuilder       sql        = new StringBuilder(@"SELECT fl_id,fl_name,st_no,part_no,step_order as step, AngleResult as angle, TorqueResult as torque FROM  dbo.View_mg_sys_log where 1=1 and Len(AngleResult) > 0");
            List <SqlParameter> parameters = new List <SqlParameter>();

            //System.Diagnostics.Debug.Write();

            if (string.IsNullOrEmpty(fl_id) == true || string.IsNullOrEmpty(st_no) == true || string.IsNullOrEmpty(part_no) == true)
            {
                List <mg_sys_log> list = new List <mg_sys_log>();
                return(list);
            }
            else
            {
                if (string.IsNullOrEmpty(fl_id) == false)
                {
                    sql.Append(" and fl_id=@fl_id");
                    parameters.Add(new SqlParameter("@fl_id", SqlDbType.NVarChar)
                    {
                        Value = fl_id
                    });
                }
                if (string.IsNullOrEmpty(st_no) == false)
                {
                    sql.Append(" and st_no=@st_no");
                    parameters.Add(new SqlParameter("@st_no", SqlDbType.NVarChar)
                    {
                        Value = st_no
                    });
                }
                if (string.IsNullOrEmpty(part_no) == false)
                {
                    sql.Append(" and part_no=@part_no");
                    parameters.Add(new SqlParameter("@part_no", SqlDbType.NVarChar)
                    {
                        Value = part_no
                    });
                }
                sql.Append(" order by fl_name, st_no, part_no, step");
                DataTable table = SqlHelper.GetDataDataTable(SqlHelper.SqlConnString, CommandType.Text, sql.ToString(), parameters.ToArray());
                foreach (DataRow row in table.Rows)
                {
                    decimal TorqueResult = 0;
                    string  str          = Convert.ToString(row["torque"].ToString().Replace("Nm", ""));
                    if (!String.IsNullOrEmpty(str))
                    {
                        TorqueResult = Convert.ToDecimal(str);
                    }
                    decimal AngleResult = 0;
                    str = Convert.ToString(row["angle"].ToString().Replace("°", ""));
                    if (!String.IsNullOrEmpty(str))
                    {
                        AngleResult = Convert.ToDecimal(str);
                    }


                    result.Add(new mg_sys_log()
                    {
                        fl_name      = DataHelper.GetCellDataToStr(row, "fl_name"),
                        st_no        = DataHelper.GetCellDataToStr(row, "st_no"),
                        part_no      = DataHelper.GetCellDataToStr(row, "part_no"),
                        step_order   = NumericParse.StringToInt(row["step"] as string),
                        TorqueResult = TorqueResult.ToString(),
                        AngleResult  = AngleResult.ToString()
                    });
                }
                return(result);
            }
        }