示例#1
0
        /// <summary>
        /// Save a new fabrikat to the database
        /// </summary>
        /// <param name="ident"></param>
        /// <param name="f"></param>
        /// <returns></returns>
        /// 2019-04-03 KJBO
        public FabrikatCL saveFabrikat(string ident, FabrikatCL f)
        {
            FabrikatCL resp = new FabrikatCL();

            resp.ErrCode    = 0;
            resp.ErrMessage = "";
            CReparator cr      = new CReparator();
            int        identOK = cr.checkIdent(ident);

            if (identOK == -1)
            {
                resp.ErrCode    = -10;
                resp.ErrMessage = "Ogiltigt login";
                return(resp);
            }
            if (f.Fabrikat == "")
            {
                resp.ErrCode    = -1;
                resp.ErrMessage = "Fabrikat måste anges";
                return(resp);
            }

            string exists = fabrikatExists(f.Fabrikat);

            if (exists != "0" && exists != "1")
            {
                resp.ErrCode    = -100;
                resp.ErrMessage = "Fel vid kontroll av fabrikat. Felmeddelande : " + exists;
                if (resp.ErrMessage.Length > 2000)
                {
                    resp.ErrMessage = resp.ErrMessage.Substring(1, 2000);
                }
                return(resp);
            }

            if (exists == "1")
            {
                resp.ErrCode    = 100;
                resp.ErrMessage = "Fabrikat finns redan registrerat";
                return(resp);
            }

            string sSql = getInsertSQL();
            NxParameterCollection pc = new NxParameterCollection();

            pc.Add("fabrikat", f.Fabrikat);
            pc.Add("reg", "System");
            pc.Add("regdat", System.DateTime.Now);
            string errText = "";
            int    iRc     = cdb.updateData(sSql, ref errText, pc);

            if (errText != "")
            {
                if (errText.Length > 2000)
                {
                    errText = errText.Substring(1, 2000);
                }

                resp.ErrCode    = -100;
                resp.ErrMessage = errText;
                return(resp);
            }
            CComboValues      cbv      = new CComboValues();
            List <FabrikatCL> respList = cbv.getFabrikat("", f.Fabrikat);

            if (respList.Count == 1)
            {
                return(respList[0]);
            }
            return(resp);
        }
示例#2
0
 /// <summary>
 /// Save a new fabrikat to the database
 /// </summary>
 /// <param name="ident"></param>
 /// <param name="f"></param>
 /// <returns></returns>
 /// 2019-04-03 KJBO
 public FabrikatCL saveFabrikat(string ident, FabrikatCL f)
 {
     Basdata.CFabrikat fabr = new Basdata.CFabrikat();
     return(fabr.saveFabrikat(ident, f));
 }
示例#3
0
        public List <FabrikatCL> getFabrikat(string ident, string fabrikat)
        {
            List <FabrikatCL> lf = new List <FabrikatCL>();

            if (ident != "")
            {
                CReparator cr      = new CReparator();
                int        identOK = cr.checkIdent(ident);

                if (identOK == -1)
                {
                    FabrikatCL f = new FabrikatCL();
                    f.ErrCode    = -10;
                    f.ErrMessage = "Ogiltigt login";
                    lf.Add(f);
                    return(lf);
                }
            }

            string sSql = " select fabrikat "
                          + " from fabrikat ";

            if (fabrikat != "")
            {
                sSql += " where fabrikat = :fabrikat ";
            }
            sSql += " order by fabrikat ";

            string errText           = "";
            NxParameterCollection pc = new NxParameterCollection();

            if (fabrikat != "")
            {
                pc.Add("fabrikat", fabrikat);
            }
            DataTable dt = cdb.getData(sSql, ref errText, pc);

            int errCode = -100;

            if (errText == "" && dt.Rows.Count == 0)
            {
                errText = "Inga fabrikat finns tillgängliga";
                errCode = 0;
            }

            if (errText != "")
            {
                if (errText.Length > 2000)
                {
                    errText = errText.Substring(1, 2000);
                }
                FabrikatCL f = new FabrikatCL();
                f.ErrCode    = errCode;
                f.ErrMessage = errText;
                lf.Add(f);
                return(lf);
            }


            foreach (DataRow dr in dt.Rows)
            {
                FabrikatCL f = new FabrikatCL();
                f.Fabrikat   = dr["fabrikat"].ToString();
                f.ErrCode    = 0;
                f.ErrMessage = "";
                lf.Add(f);
            }
            return(lf);
        }