Beispiel #1
0
        private void VerifyFixedAnalysisCode()
        {
            int    fixedCount        = 10;
            string fixedAnalysisCode = string.Empty;

            using (var ctx = new EF6.RT2020Entities())
            {
                for (int i = 1; i <= fixedCount; i++)
                {
                    fixedAnalysisCode = i.ToString().PadLeft(2, '0');

                    //string sql = "AnalysisCode = '" + fixedAnalysisCode + "'";
                    var oACode = ctx.PosAnalysisCode.Where(x => x.AnalysisCode == fixedAnalysisCode).FirstOrDefault();
                    if (oACode == null)
                    {
                        oACode = new EF6.PosAnalysisCode();
                        oACode.AnalysisCodeId = Guid.NewGuid();
                        oACode.AnalysisCode   = fixedAnalysisCode;
                        oACode.AnalysisType   = fixedAnalysisCode;
                        oACode.CodeInitial    = fixedAnalysisCode;
                        oACode.CodeName       = fixedAnalysisCode;
                        oACode.CodeName_Chs   = fixedAnalysisCode;
                        oACode.CodeName_Cht   = fixedAnalysisCode;
                        oACode.Mandatory      = true;
                        oACode.DownloadToPOS  = false;
                        oACode.CreatedBy      = ConfigHelper.CurrentUserId;
                        oACode.CreatedOn      = DateTime.Now;
                        oACode.ModifiedBy     = ConfigHelper.CurrentUserId;
                        oACode.ModifiedOn     = DateTime.Now;

                        ctx.PosAnalysisCode.Add(oACode);
                    }
                }
            }
        }
Beispiel #2
0
 private static string GetFormatedText(EF6.PosAnalysisCode 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);
 }
Beispiel #3
0
        /// <summary>
        /// Get a EF6.PosAnalysisCode object from the database using the given AnalysisCodeId
        /// </summary>
        /// <param name="analysisCodeId">The primary key value</param>
        /// <returns>A EF6.PosAnalysisCode object</returns>
        public static EF6.PosAnalysisCode Get(Guid analysisCodeId)
        {
            EF6.PosAnalysisCode result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.PosAnalysisCode.Where(x => x.AnalysisCodeId == analysisCodeId).AsNoTracking().FirstOrDefault();
            }

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

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

            return(result);
        }
Beispiel #5
0
        private bool Save()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.PosAnalysisCode.Find(this.AnalysisCodeId);
                if (item == null)
                {
                    item = new EF6.PosAnalysisCode();

                    item.AnalysisCodeId = Guid.NewGuid();
                    item.AnalysisCode   = txtCode.Text;

                    item.CreatedBy = ConfigHelper.CurrentUserId;
                    item.CreatedOn = DateTime.Now;

                    ctx.PosAnalysisCode.Add(item);
                    _CodeId = item.AnalysisCodeId;
                }
                item.AnalysisType = txtType.Text;
                item.CodeInitial  = txtInitial.Text;
                item.CodeName     = txtName.Text;
                item.CodeName_Chs = txtNameAlt1.Text;
                item.CodeName_Cht = txtNameAlt2.Text;
                if ((Guid)cboParentAnalysisCode.SelectedValue != Guid.Empty)
                {
                    item.ParentCode = (Guid)cboParentAnalysisCode.SelectedValue;
                }
                item.DownloadToPOS = chkDownloadToPoS.Checked;
                item.Mandatory     = chkMandatory.Checked;

                item.ModifiedBy = ConfigHelper.CurrentUserId;
                item.ModifiedOn = DateTime.Now;

                ctx.SaveChanges();

                // log activity (New Record)
                RT2020.Controls.Log4net.LogInfo(RT2020.Controls.Log4net.LogAction.Create, item.ToString());

                this.AnalysisCodeId = item.AnalysisCodeId;
                Helper.DesktopHelper.RefreshMainList <AnalysisCodeList>();

                result = true;
            }

            return(result);
        }