Esempio n. 1
0
        /// <summary>
        /// Get all available repKat for
        /// timeregistration version 2
        /// </summary>
        /// <param name="ident"></param>
        /// <returns></returns>
        /// 2017-03-14 KJBO
        public List <RepKatCL> getRepKat(string ident)
        {
            int             identOK = checkIdent(ident);
            List <RepKatCL> repList = new List <RepKatCL>();


            if (identOK == -1)
            {
                RepKatCL rep = new RepKatCL();
                rep.RepKatID   = "";
                rep.RepKat     = "";
                rep.ErrCode    = -10;
                rep.ErrMessage = "Ogiltigt login";
                repList.Add(rep);
                return(repList);
            }

            string sSql = " select rep_kat_id, rep_kat "
                          + " from rep_kat "
                          + " order by rep_kat ";

            string    errSt = "";
            DataTable dt    = cdb.getData(sSql, ref errSt);

            int errCode = -100;

            if (errSt == "" && dt.Rows.Count == 0)
            {
                errSt   = "Reparatörskategorier saknas";
                errCode = 0;
            }


            if (errSt != "")
            {
                RepKatCL rep = new RepKatCL();
                if (errSt.Length > 2000)
                {
                    errSt = errSt.Substring(1, 2000);
                }
                rep.ErrCode    = errCode;
                rep.ErrMessage = errSt;
                repList.Add(rep);
                return(repList);
            }

            foreach (DataRow dr in dt.Rows)
            {
                RepKatCL rep = new RepKatCL();
                rep.RepKatID = dr["rep_kat_id"].ToString();
                rep.RepKat   = dr["rep_kat"].ToString();
                repList.Add(rep);
            }

            return(repList);
        }
Esempio n. 2
0
        /// <summary>
        /// New function that always returns the rep_kat for one reparator
        /// </summary>
        /// <param name="AnvID"></param>
        /// <returns></returns>
        /// 2017-09-06 KJBO
        private RepKatCL getDefaultRepKat2(string AnvID)
        {
            string sSql = "SELECT rk.rep_kat_id, rk.rep_kat "
                          + " FROM reparator r "
                          + " join rep_kat rk on r.rep_kat_id = rk.rep_kat_id "
                          + " where r.AnvID = :AnvID "
                          + " union "
                          + " select rep_kat_id, rep_kat "
                          + " from rep_kat "
                          + " where stdkat = true ";


            NxParameterCollection np = new NxParameterCollection();

            np.Add("AnvID", AnvID);

            string    errSt = "";
            DataTable dt    = cdb.getData(sSql, ref errSt, np);


            int errCode = -100;

            if (errSt != "")
            {
                RepKatCL rep = new RepKatCL();
                if (errSt.Length > 2000)
                {
                    errSt = errSt.Substring(1, 2000);
                }
                rep.ErrCode    = errCode;
                rep.ErrMessage = errSt;
                return(rep);
            }

            if (dt.Rows.Count > 0)
            {
                RepKatCL rep = new RepKatCL();
                rep.RepKatID   = dt.Rows[0]["rep_kat_id"].ToString();
                rep.RepKat     = dt.Rows[0]["rep_kat"].ToString();
                rep.ErrCode    = 0;
                rep.ErrMessage = "";
                return(rep);
            }

            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Determines if the AnvID is administrator for the current order
        /// If so the function will return the administrator RepCat.
        /// Otherwise it will return the default RepKat.
        /// repKat
        /// </summary>
        /// <param name="ident"></param>
        /// <param name="AnvID"></param>
        /// <param name="VartOrdernr"></param>
        /// <returns></returns>
        /// 2017-09-06 Always return the default rep-kat for one reparator (AnvID)
        public RepKatCL getDefaultRepKat(string ident, string AnvID, string VartOrdernr)
        {
            int identOK = checkIdent(ident);

            if (identOK == -1)
            {
                RepKatCL rep = new RepKatCL();
                rep.RepKatID   = "";
                rep.RepKat     = "";
                rep.ErrCode    = -10;
                rep.ErrMessage = "Ogiltigt login";
                return(rep);
            }

            return(getDefaultRepKat2(AnvID));

            /*
             * string sSql = "select coalesce(orderAdmin,'') orderAdmin "
             + "from serviceHuvud "
             + "where vart_ordernr = :vart_ordernr ";
             +
             + NxParameterCollection np = new NxParameterCollection();
             + np.Add("vart_ordernr", VartOrdernr);
             +
             + string errSt = "";
             + DataTable dt = cdb.getData(sSql, ref errSt, np);
             +
             + string orderAdmin = "";
             +
             + int errCode = -100;
             +
             + if (errSt != "")
             + {
             +  RepKatCL rep = new RepKatCL();
             +  if (errSt.Length > 2000)
             +      errSt = errSt.Substring(1, 2000);
             +  rep.ErrCode = errCode;
             +  rep.ErrMessage = errSt;
             +  return rep;
             + }
             +
             + if (dt.Rows.Count > 0)
             + {
             +  orderAdmin = dt.Rows[0]["orderAdmin"].ToString();
             + }
             +
             + sSql = "SELECT rep_kat_id, rep_kat "
             + "FROM rep_kat "
             + " where stdkat = :stdkat ";
             +
             + np = new NxParameterCollection();
             +
             + if (AnvID == orderAdmin)
             +  np.Add("stdkat", false);
             + else
             +  np.Add("stdkat", true);
             +
             +
             + dt = cdb.getData(sSql, ref errSt, np);
             +
             + errCode = -100;
             +
             + if (errSt == "" && dt.Rows.Count == 0)
             + {
             +  errSt = "Reparatörskategori kan ej utvärderas";
             +  errCode = 0;
             + }
             +
             +
             + if (errSt != "")
             + {
             +  RepKatCL rep = new RepKatCL();
             +  if (errSt.Length > 2000)
             +      errSt = errSt.Substring(1, 2000);
             +  rep.ErrCode = errCode;
             +  rep.ErrMessage = errSt;
             +  return rep;
             + }
             +
             + if (dt.Rows.Count > 0)
             + {
             +  RepKatCL rep = new RepKatCL();
             +  rep.RepKatID = dt.Rows[0]["rep_kat_id"].ToString();
             +  rep.RepKat = dt.Rows[0]["rep_kat"].ToString();
             +  rep.ErrCode = 0;
             +  rep.ErrMessage = "";
             +  return rep;
             + }
             +
             + return null;
             */
        }