Exemple #1
0
        /// <summary>
        /// Loads the records from the DbSet into the ViewModel. This function designed for recursive use
        /// </summary>
        /// <param name="Project_ID"></param>
        /// <param name="Parent_ID"></param>
        /// <returns>Observable collection of VMObjects</returns>
        private void Load()
        {
            using (EDBEntities eDB = new EDBEntities())
            {
                foreach (tblType Rec in (from o in eDB.tblTypes where (o.Project_ID == Globals.Project_ID) orderby o.ShowOrder select o))
                {
                    TypeModel typeItem = new TypeModel
                    {
                        ID          = Rec.ID,
                        Project_ID  = Rec.Project_ID,
                        Type        = Rec.Type,
                        Description = Rec.Description,
                        Image       = Rec.Image,
                        ShowOrder   = Rec.ShowOrder.GetValueOrDefault(999),
                        TypeGroup   = Rec.TypeGroup,
                        IsChanged   = false,
                    };
                    Types.Add(typeItem);
                }

                TypeGroups.Add("Object");
                TypeGroups.Add("Property");
                TypeGroups.Add("Template");
                TypeGroups.Add("Requirement");
            }
            IsChanged = false;
        }
Exemple #2
0
        public bool AddTypeGroup(String sName)
        {
            if (TypeGroupExists(sName))
            {
                return(false);
            }
            TypeGroup oTypeGroup = new TypeGroup(sName);

            TypeGroups.Add(oTypeGroup);
            return(true);
        }
        public bool DeleteCategory(String sTypeName)
        {
            TypeGroup oTypeGroup = FindTypeGroup(sTypeName);

            if (oTypeGroup != null)
            {
                TypeGroups.Remove(oTypeGroup);
                return(true);
            }
            return(false);
        }
        public bool InsertTypeGroup(String sTypeName)
        {
            if (TypeGroupExists(sTypeName))
            {
                Form1.LogError("TypeName " + sTypeName + " already exists");
                return(false);
            }
            TypeGroup oTypeGroup = new TypeGroup(sTypeName);

            TypeGroups.Add(oTypeGroup);
            return(true);
        }
Exemple #5
0
        /// <summary>Corrects attribute values and display values</summary>
        /// <param name="att">The instance of the ItemAttributeData class to correct</param>
        public static void CorrectAttributeValue(ItemAttribData att)
        {
            if (att == null)
            {
                return;
            }

            // Alter data based on unit ID
            switch (AttributeTypes[att.Id].UnitId)
            {
            case 108:
                att.Value        = 100 - (att.Value * 100);
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                break;

            case 109:
                att.Value        = (att.Value * 100) - 100;
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                break;

            case 111:
                att.Value        = (att.Value - 1) * 100;
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                break;

            case 101:
                att.Value        = att.Value / 1000;
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                break;

            case 115:

                // groupID
                if (TypeGroups.ContainsKey(Convert.ToInt32(att.Value, CultureInfo.CurrentCulture)))
                {
                    att.DisplayValue = TypeGroups[Convert.ToInt32(att.Value, CultureInfo.CurrentCulture)];
                }
                else
                {
                    att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                }
                att.Unit = string.Empty;
                break;

            case 116:

                // typeID
                att.DisplayValue = "Unknown";
                if (Types.ContainsKey(Convert.ToInt32(att.Value)))
                {
                    att.DisplayValue = Types[Convert.ToInt32(att.Value, CultureInfo.CurrentCulture)].Name;
                }

                att.Unit = string.Empty;
                break;

            case 119:
            case 140:
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                att.Unit         = string.Empty;
                break;

            default:
                att.DisplayValue = Convert.ToString(att.Value, CultureInfo.CurrentCulture);
                break;
            }
        }
Exemple #6
0
        public HttpResponseMessage savetypegroups(TypeGroups b)
        {
            LogTraceWriter traceWriter = new LogTraceWriter();

            traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "savetypegroups credentials....");

            //connect to database
            SqlConnection conn = new SqlConnection();

            try
            {
                //connetionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "InsUpdTypeGroups";
                cmd.Connection  = conn;
                conn.Open();


                SqlParameter Gid = new SqlParameter();
                Gid.ParameterName = "@Name";
                Gid.SqlDbType     = SqlDbType.VarChar;
                Gid.Value         = b.Name;
                cmd.Parameters.Add(Gid);

                SqlParameter Gim = new SqlParameter();
                Gim.ParameterName = "@Id";
                Gim.SqlDbType     = SqlDbType.Int;
                Gim.Value         = Convert.ToString(b.Id);
                cmd.Parameters.Add(Gim);

                SqlParameter pid = new SqlParameter();
                pid.ParameterName = "@Description";
                pid.SqlDbType     = SqlDbType.VarChar;
                pid.Value         = b.Description;
                cmd.Parameters.Add(pid);

                SqlParameter llid = new SqlParameter();
                llid.ParameterName = "@Active";
                llid.SqlDbType     = SqlDbType.Int;
                llid.Value         = 1;// b.Active;
                //llid.Value = b.Active;
                cmd.Parameters.Add(llid);

                SqlParameter flag = new SqlParameter();
                flag.ParameterName = "@insupdflag";
                flag.SqlDbType     = SqlDbType.VarChar;
                flag.Value         = b.insupddelflag;
                cmd.Parameters.Add(flag);



                //DataSet ds = new DataSet();
                //SqlDataAdapter db = new SqlDataAdapter(cmd);
                //db.Fill(ds);
                // Tbl = Tables[0];
                cmd.ExecuteScalar();
                conn.Close();
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "savetypegroups Credentials completed.");
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                string str = ex.Message;

                traceWriter.Trace(Request, "1", TraceLevel.Info, "{0}", "Error in savetypegroups:" + ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }
        }
        public HttpResponseMessage savetypegroups(TypeGroups b)
        {
            //connect to database
            SqlConnection conn = new SqlConnection();

            try
            {
                //connetionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EES_DB_ConnectionString"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "InsUpdTypeGroups";
                cmd.Connection  = conn;
                conn.Open();


                SqlParameter Gid = new SqlParameter();
                Gid.ParameterName = "@Name";
                Gid.SqlDbType     = SqlDbType.VarChar;
                Gid.Value         = b.Name;
                cmd.Parameters.Add(Gid);

                SqlParameter Gim = new SqlParameter();
                Gim.ParameterName = "@Id";
                Gim.SqlDbType     = SqlDbType.Int;
                Gim.Value         = Convert.ToString(b.Id);
                cmd.Parameters.Add(Gim);

                SqlParameter pid = new SqlParameter();
                pid.ParameterName = "@Description";
                pid.SqlDbType     = SqlDbType.VarChar;
                pid.Value         = b.Description;
                cmd.Parameters.Add(pid);

                SqlParameter llid = new SqlParameter();
                llid.ParameterName = "@Active";
                llid.SqlDbType     = SqlDbType.Int;
                llid.Value         = b.Active;
                cmd.Parameters.Add(llid);

                SqlParameter flag = new SqlParameter();
                flag.ParameterName = "@insupdflag";
                flag.SqlDbType     = SqlDbType.VarChar;
                flag.Value         = b.insupddelflag;
                cmd.Parameters.Add(flag);


                cmd.ExecuteScalar();
                conn.Close();

                //Logger.Trace(LogCategory.WebApp, "savetypegroups Credentials completed.", LogLevel.Information, null);
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                string str = ex.Message;


                //Logger.Error(ex, LogCategory.WebApp, "An error occured in savetypegroups() procedure", LogLevel.Error, null);
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }
        }