private void SetSmartTags()
        {
            string[] orderBy      = new string[] { "Priority" };
            var      smartTagList = SmartTag4StaffEx.GetListOrderBy(orderBy, true);

            SmartTagHelper oTag = new SmartTagHelper(this);

            oTag.StaffSmartTagList = smartTagList;
            oTag.SetSmartTags();
        }
        private bool IsValid()
        {
            bool result = true;

            #region Tag Code 唔可以吉
            errorProvider.SetError(txtTagCode, string.Empty);
            if (txtTagCode.Text.Length == 0)
            {
                errorProvider.SetError(txtTagCode, "Cannot be blank!");
                return(false);
            }
            #endregion

            #region 新增,要 check Tag Code 係咪 in use
            errorProvider.SetError(txtTagCode, string.Empty);
            if (_SmartTagId == Guid.Empty && SmartTag4StaffEx.IsTagCodeInUse(txtTagCode.Text.Trim()))
            {
                errorProvider.SetError(txtTagCode, "Tag Code in use");
                return(false);
            }
            #endregion

            return(result);
        }
        private void Delete()
        {
            var result = SmartTag4StaffEx.DeleteOptionsToo(_SmartTagId);

            MessageBox.Show(result ? "Record Removed" : "Can't Delete Record...", "Delete Result");
        }
Beispiel #4
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            string whereClause = string.Empty;

            EF6.Staff staff = null;
            if (!txtStaff.Text.Trim().Equals("*"))
            {
                staff = StaffEx.GetByStaffNumber(txtStaff.Text.Trim());
            }

            var smartTag4Staff = SmartTag4StaffEx.GetByTagCode("HKID");

            if (!txtHKID.Text.Trim().Equals("*"))
            {
                if (smartTag4Staff != null)
                {
                    if (staff != null)
                    {
                        whereClause = " StaffId = '" + staff.StaffId.ToString() + "' AND TagId = '" + smartTag4Staff.TagId.ToString() + "' AND SmartTagValue = '" + txtHKID.Text.Trim() + "'";
                    }
                    else
                    {
                        whereClause = " TagId = '" + smartTag4Staff.TagId.ToString() + "' AND SmartTagValue = '" + txtHKID.Text.Trim() + "'";
                    }
                }
            }
            else
            {
                if (smartTag4Staff != null)
                {
                    if (staff != null)
                    {
                        whereClause = " StaffId = '" + staff.StaffId.ToString() + "' AND TagId = '" + smartTag4Staff.TagId.ToString() + "'";
                    }
                    else
                    {
                        whereClause = " TagId = '" + smartTag4Staff.TagId.ToString() + "'";
                    }
                }
            }

            using (var ctx = new EF6.RT2020Entities())
            {
                var list = ctx.StaffSmartTag.SqlQuery(
                    String.Format(
                        "Select * from StaffSmartTag Where {0}",
                        String.IsNullOrEmpty(whereClause) ? "1 = 1" : whereClause
                        ))
                           .AsNoTracking()
                           .ToList();

                if (list.Count > 0)
                {
                    int iCount = 1;
                    foreach (var item in list)
                    {
                        ListViewItem objItem = this.lvStaffList.Items.Add(iCount.ToString());
                        if (staff == null)
                        {
                            var sta = StaffEx.GetByStaffId(item.StaffId);
                            if (sta != null)
                            {
                                objItem.SubItems.Add(sta.StaffNumber);
                            }
                        }
                        else
                        {
                            objItem.SubItems.Add(txtStaff.Text.Trim());
                        }

                        objItem.SubItems.Add(item.SmartTagValue);

                        iCount++;
                    }
                }
            }
        }