Esempio n. 1
0
 private void BindTextEdit(TraindateTicketRule _currentSTR)
 {
     if (_currentSTR == null)
     {
         _currentSTR = new TraindateTicketRule();
     }
     this.Btn_TicketRule.EditValue = _currentSTR.TicketRuleCode;
     this.txt_Count.EditValue      = _currentSTR.Count;
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TraindateTicketRule GetModel(int TrainDateID, int TicketRuleID)
        {
            var strSql = new StringBuilder();

            strSql.Append(@"REPOS:Ticket.TraindateTicketRule.GetModel");
            var parameters = new List <QfParameter>();

            parameters.Add(new QfParameter("@TrainDateID", TrainDateID));
            parameters.Add(new QfParameter("@TicketRuleID", TicketRuleID));

            var model = new TraindateTicketRule();
            var ds    = Query(strSql.ToString(), parameters.ToArray());

            return(ModelConvert.ToModel <TraindateTicketRule>(ds));
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TraindateTicketRule model)
        {
            var strSql = new StringBuilder();

            strSql.Append(@"REPOS:Ticket.TraindateTicketRule.Update");
            var parameters = new List <QfParameter>();

            parameters.Add(new QfParameter("@TrainDateID", model.TrainDateID));
            parameters.Add(new QfParameter("@TicketRuleID", model.TicketRuleID));
            parameters.Add(new QfParameter("@Count", model.Count));
            parameters.Add(new QfParameter("@OperateID", model.OperateID));
            parameters.Add(new QfParameter("@OperateTime", model.OperateTime));

            try
            {
                var rows = ExecuteSql(strSql.ToString(), parameters.ToArray());
                return(rows > 0);
            }
            catch (QfException ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
 private void barButtonItem_add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (e.Item == barButtonItem_add)
     {
         txt_Count.Enabled      = true;
         Btn_TicketRule.Enabled = true;
         TraindateTicketRule ticket = new TraindateTicketRule();
         ticket.TicketRuleID           = -1;
         this._currentSTR.TicketRuleID = ticket.TicketRuleID;
         this.strlist.Add(ticket);
         this.gc_traindate_ticket_rule.DataSource = this.strlist;
         this.gc_traindate_ticket_rule.RefreshDataSource();
         this.gv_traindate_ticket_rule.FocusedRowHandle = this.gv_traindate_ticket_rule.GetRowHandle(this.strlist.Count - 1);
         this.formState = FormState.New;
     }
     else if (e.Item == barButtonItem_delete)
     {
         if (strlist.Count == 0)
         {
             MsgBox.ShowInfo("请选中一条数据");
             return;
         }
         else
         {
             TraindateTicketRule item = (TraindateTicketRule)gv_traindate_ticket_rule.GetFocusedRow();
             new TraindateTicketRuleDao().Delete(item.TrainDateID, item.TicketRuleID);
             strlist.Remove(item);
             MsgBox.ShowInfo("删除成功");
         }
         this.gc_traindate_ticket_rule.RefreshDataSource();
     }
     else if (e.Item == barButtonItem_edit)
     {
         this._currentSTR = this.gv_traindate_ticket_rule.GetFocusedRow() as TraindateTicketRule;
         if (this._currentSTR != null)
         {
             this._itemcopy = (TraindateTicketRule)this._currentSTR.Copy();//保存副本,防止取消编辑
             if (this._itemcopy != null)
             {
                 this.ChangeControlState("Modify");
             }
         }
     }
     else if (e.Item == barButtonItem_save)
     {
         if (txt_Count.Text == "")
         {
             MsgBox.ShowInfo("赠送数量不为空");
             return;
         }
         if (Btn_TicketRule.Text == null)
         {
             MsgBox.ShowInfo("规则编号不为空");
             return;
         }
         this._currentSTR.TicketRuleCode = Btn_TicketRule.Text;
         this._currentSTR.Count          = Convert.ToInt32(txt_Count.Text);
         this._currentSTR.TrainDateID    = traindateID;
         _currentSTR.OperateID           = Program.CurrentEmployee.EmployeeID;
         _currentSTR.OperateTime         = DateTime.Now;
         bool result = false;
         if (this.formState == FormState.New)
         {
             if (_currentSTR.TicketRuleID == -1)
             {
                 _currentSTR.TicketRuleID = Convert.ToInt32(this.Btn_TicketRule.Tag);
             }
             if (new TraindateTicketRuleDao().Exist(_currentSTR.TrainDateID, _currentSTR.TicketRuleID))
             {
                 MsgBox.ShowInfo("已经存在选中数据!");
                 return;
             }
             else
             {
                 result = new TraindateTicketRuleDao().Add(_currentSTR);
             }
         }
         else //保存修改
         {
             result = new TraindateTicketRuleDao().Update(_currentSTR);
         }
         if (result)
         {
             this.formState = FormState.Normal;
             int _index = this.gv_traindate_ticket_rule.GetFocusedDataSourceRowIndex();
             this.gc_traindate_ticket_rule.RefreshDataSource();
             this.gv_traindate_ticket_rule.FocusedRowHandle = _index;
             MsgBox.ShowInfo("保存成功");
         }
         else
         {
             MsgBox.ShowInfo("保存失败");
         }
     }
 }
Esempio n. 5
0
 private void gv_traindate_ticket_rule_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     this._currentSTR = this.gv_traindate_ticket_rule.GetFocusedRow() as TraindateTicketRule;
     this.BindTextEdit(_currentSTR);
 }