コード例 #1
0
        public PrintResponse GetPrintContent(string SN)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}(SN:{1})", methodName, SN);
            try
            {
                //1.检查传进来的参数
                Execute.ValidateParameter(SN);

                //2.获取DB中的数据
                PrintResponse printResponse = Execute.GetPrintContentInfo(SN);
                logger.DebugFormat("Reponse data:{0}", printResponse.ToString());
                return printResponse;
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                PrintResponse printResponse = new PrintResponse();
                printResponse.SN = SN;
                printResponse.PN = "";
                printResponse.Warranty = "";
                printResponse.MN = "";
                printResponse.Status = -2;
                printResponse.ErrorMsg = e.Message;

                logger.DebugFormat("Reponse data:{0}", printResponse.ToString());

                return printResponse;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
            
        }
コード例 #2
0
ファイル: SqlStatment.cs プロジェクト: wra222/testgit
        //GetPrintContent
        public static PrintResponse GetPrintContentBySN(string sn)
        {
            string sqlStr = @"select distinct a.CUSTSN as SN,b.Value as PN,c.Value as Warranty,d.Value as MN
                              from   Product a,ModelInfo b,ModelInfo c,ModelInfo d
                              where  a.CUSTSN=@SN 
                                     and a.Model=b.Model 
                                     and a.Model=c.Model
                                     and a.Model=d.Model
                                     and b.Name='PN'
                                     and c.Name='WARRANTY'
                                     and d.Name='MN1'";

            DataTable dt = SqlHelper.ExecuteDataTable(System.Data.CommandType.Text,
                sqlStr, new SqlParameter("@SN", sn));

            if (dt == null || dt.Rows.Count == 0)
            {
                PrintResponse printResponse = new PrintResponse();
                printResponse.SN = sn;
                printResponse.PN = "";
                printResponse.Warranty = "";
                printResponse.MN = "";
                printResponse.Status=-1;
                printResponse.ErrorMsg = "The SN: " + sn + " is not exist in DB!";

                return printResponse;
            }
            else 
            {
                return ToPrintResponse(dt.Rows[0]);
            }
        }
コード例 #3
0
ファイル: SqlStatment.cs プロジェクト: wra222/testgit
        private static PrintResponse ToPrintResponse(DataRow row)
        {
            PrintResponse printResponse = new PrintResponse();
            printResponse.SN = (string)row["SN"];
            printResponse.PN = (string)row["PN"];
            printResponse.Warranty = (string)row["Warranty"];
            printResponse.MN = (string)row["MN"];
            printResponse.ErrorMsg = "";
            printResponse.Status = 1;

            return printResponse;
        }