Exemplo n.º 1
0
        /// <summary>
        /// Find Cards
        /// </summary>
        private void OKBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(CardSnTB.Text))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("请输入十进制卡号", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CardXSnTB.Text))
                {
                    CardXSnTB.Focus();
                    MessageBox.Show("请输入十六进制卡号", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CardSn       = CardSnTB.Text.Trim();
                XCardSn      = CardXSnTB.Text.Trim();
                DialogResult = System.Windows.Forms.DialogResult.OK;
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.FindCardDialog.OKBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// CardXSn TextBox Text Changed Event.
 /// </summary>
 private void CardXSnTB_TextChanged(object sender, EventArgs e)
 {
     try {
         CardSnTB.TextChanged -= CardSnTB_TextChanged;
         if (String.IsNullOrWhiteSpace(CardXSnTB.Text))
         {
             CardSnTB.Clear();
             CardSnTB.ReadOnly = false;
         }
         else
         {
             CardSnTB.Text     = Common.GetCardSn16to10(CardXSnTB.Text);
             CardSnTB.ReadOnly = true;
         }
     } catch (Exception err) {
         Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.FindCardDialog.CardXIDTB.TextChanged", err.Message, err.StackTrace);
         MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     } finally {
         CardSnTB.TextChanged += CardSnTB_TextChanged;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Form Shown Event.
        /// </summary>
        private void SaveCardForm_Shown(object sender, EventArgs e)
        {
            try {
                SaveBtn.Enabled = false;
                if (CurBehavior == EnmSaveBehavior.Null || CurCard == null)
                {
                    MessageBox.Show("非法的构造参数", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DialogResult = System.Windows.Forms.DialogResult.Abort;
                    return;
                }

                BindCardTypeCombobox();
                BindCardReasonCombobox();
                CardSnTB.Focus();
                CardSnTB.ReadOnly        = CurBehavior == EnmSaveBehavior.Edit;
                SetCardBtn.Enabled       = CurBehavior == EnmSaveBehavior.Add;
                EmpNameTB.Text           = String.IsNullOrWhiteSpace(CurCard.WorkerId) ? String.Empty : String.Format("{0} - {1}", CurCard.WorkerId, CurCard.WorkerName);
                CardSnTB.Text            = CurCard.CardSn;
                CardTypeCB.SelectedValue = (Int32)CurCard.CardType;
                BeginTimeDTP.Value       = CurCard.BeginTime;
                CardUIDTB.Text           = CurCard.UID;
                CardPwdTB.Text           = CurCard.Pwd;
                var reasonId = GetCardReasonID(CurCard.BeginReason);
                if (reasonId == 0)
                {
                    BeginReasonTB.Text = CurCard.BeginReason;
                }
                BeginReasonCB.SelectedValue = reasonId;
                CommentTB.Text    = CurCard.Comment;
                EnabledCB.Checked = CurCard.Enabled;
                SaveBtn.Enabled   = true;
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardForm.Shown", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Save Card.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(CurCard.WorkerId))
                {
                    EmpNameTB.Clear();
                    CurCard.DepId      = String.Empty;
                    CurCard.DepName    = String.Empty;
                    CurCard.WorkerId   = String.Empty;
                    CurCard.WorkerName = String.Empty;
                    MessageBox.Show("请选择持卡员工", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CardSnTB.Text))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("请输入卡号", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && CardEntity.ExistCard(CardSnTB.Text.Trim()))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("卡号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //CurCard.WorkerId = null;
                //CurCard.WorkerType = null;
                //CurCard.WorkerName = null;
                //CurCard.DepId = null;
                //CurCard.DepName = null;
                CurCard.CardSn      = CardSnTB.Text.Trim();
                CurCard.CardType    = ComUtility.DBNullCardTypeHandler(CardTypeCB.SelectedValue);
                CurCard.UID         = String.IsNullOrWhiteSpace(CardUIDTB.Text) ? "00000000" : CardUIDTB.Text.Trim().PadLeft(8, '0');
                CurCard.Pwd         = String.IsNullOrWhiteSpace(CardPwdTB.Text) ? "0000" : CardPwdTB.Text.Trim().PadLeft(4, '0');
                CurCard.BeginTime   = BeginTimeDTP.Value;
                CurCard.BeginReason = Convert.ToInt32(BeginReasonCB.SelectedValue) == 0 ? BeginReasonTB.Text.Trim() : BeginReasonCB.Text;
                CurCard.Comment     = CommentTB.Text.Trim();
                CurCard.Enabled     = EnabledCB.Checked;
                var result = Common.ShowWait(() => {
                    CardEntity.SaveCards(new List <CardInfo> {
                        CurCard
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurCard, OriCard);
                    Common.WriteLog(DateTime.Now, CurBehavior == EnmSaveBehavior.Add ? EnmMsgType.Cardin : EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", String.Format("{0}卡片:[{1} - {2},{3}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurCard.CardSn, CurCard.WorkerId, CurCard.WorkerName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }