Example #1
0
        private static void FillWorkplaceChild(ref TreeNode nodes, EF6.WorkplaceZone item)
        {
            var where = string.Format("ZoneId = '{0}'", item.ZoneId);
            string[] orderBy = new string[] { "WorkplaceCode" };
            var      child   = GetList(where, orderBy);

            if (child.Count > 0)
            {
                foreach (var zone in child)
                {
                    var text = CookieHelper.CurrentLocaleId == LanguageHelper.AlternateLanguage2.Key ?
                               zone.WorkplaceName_Cht : CookieHelper.CurrentLocaleId == LanguageHelper.AlternateLanguage1.Key ?
                               zone.WorkplaceName_Chs :
                               zone.WorkplaceName;

                    var node = new TreeNode()
                    {
                        Name = "Workplace",
                        Tag  = zone.WorkplaceId,
                        Text = zone.WorkplaceCode + " - " + text
                    };

                    nodes.Nodes.Add(node);
                }
            }
        }
Example #2
0
        private bool Save()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var zone = ctx.WorkplaceZone.Find(this.ZoneId);

                if (zone == null)
                {
                    zone        = new EF6.WorkplaceZone();
                    zone.ZoneId = new Guid();

                    ctx.WorkplaceZone.Add(zone);
                    zone.ZoneCode = txtZoneCode.Text;
                }
                zone.ZoneInitial  = txtZoneInitial.Text;
                zone.ZoneName     = txtZoneName.Text;
                zone.ZoneName_Chs = txtZoneNameAlt1.Text;
                zone.ZoneName_Cht = txtZoneNameAlt2.Text;
                zone.CurrencyCode = cboCurrency.Text;
                zone.PromaryZone  = chkPrimaryZone.Checked;
                if ((Guid)cboParent.SelectedValue != Guid.Empty)
                {
                    zone.ParentZone = (Guid)cboParent.SelectedValue;
                }
                zone.Notes = txtRemarks.Text;

                ctx.SaveChanges();
                result = true;
            }

            return(result);
        }
Example #3
0
 private static string GetFormatedText(EF6.WorkplaceZone target, string[] textField, string textFormatString)
 {
     for (int i = 0; i < textField.Length; i++)
     {
         PropertyInfo pi = target.GetType().GetProperty(textField[i]);
         textFormatString = textFormatString.Replace("{" + i.ToString() + "}", pi != null ? pi.GetValue(target, null).ToString() : string.Empty);
     }
     return(textFormatString);
 }
Example #4
0
        /// <summary>
        /// Get a EF6.WorkplaceZone object from the database using the given ZoneId
        /// </summary>
        /// <param name="zoneId">The primary key value</param>
        /// <returns>A EF6.WorkplaceZone object</returns>
        public static EF6.WorkplaceZone Get(Guid zoneId)
        {
            EF6.WorkplaceZone result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.WorkplaceZone.Where(x => x.ZoneId == zoneId).AsNoTracking().FirstOrDefault();
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// Get a EF6.WorkplaceZone object from the database using the given QueryString
        /// </summary>
        /// <param name="zoneId">The primary key value</param>
        /// <returns>A EF6.WorkplaceZone object</returns>
        public static EF6.WorkplaceZone Get(string whereClause)
        {
            EF6.WorkplaceZone result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.WorkplaceZone
                         .SqlQuery(string.Format("Select * from WorkplaceZone Where {0}", whereClause))
                         .AsNoTracking()
                         .FirstOrDefault();
            }

            return(result);
        }