Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.drpTestTraining.Value))
            {
                Model.Base_TrainTypeItem newItem = new Model.Base_TrainTypeItem()
                {
                    TrainTypeId = this.TrainTypeId,
                    TrainingId  = this.drpTestTraining.Value,
                    SCount      = Funs.GetNewIntOrZero(this.txtSCount.Text),
                    MCount      = Funs.GetNewIntOrZero(this.txtMCount.Text),
                    JCount      = Funs.GetNewIntOrZero(this.txtJCount.Text),
                };

                var deleteItem = Funs.DB.Base_TrainTypeItem.FirstOrDefault(x => x.TrainTypeId == newItem.TrainTypeId && x.TrainingId == newItem.TrainingId);
                if (deleteItem != null)
                {
                    TrainTypeService.DeleteTrainTypeItemById(deleteItem.TrainTypeItemId);
                }

                TrainTypeService.AddTrainTypeItem(newItem);
                this.BindGrid();
                this.reSetTable();

                this.ShowNotify("保存成功!", MessageBoxIcon.Success);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑数据方法
        /// </summary>
        private void EditData()
        {
            if (Grid1.SelectedRowIndexArray.Length == 0)
            {
                Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
                return;
            }
            string Id            = Grid1.SelectedRowID;
            var    trainTypeItem = TrainTypeService.GetTrainTypeItemById(Id);

            if (trainTypeItem != null)
            {
                this.drpTestTraining.Value = trainTypeItem.TrainingId;
                this.txtSCount.Text        = trainTypeItem.SCount.ToString();
                this.txtMCount.Text        = trainTypeItem.MCount.ToString();
                this.txtJCount.Text        = trainTypeItem.JCount.ToString();
            }
        }