示例#1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <returns></returns>
        private string UpdateData()
        {
            string     result          = string.Empty;
            List <int> successRowIndex = new List <int>();

            XF.Model.Base_Course model;
            foreach (int index in lstUpdate)
            {
                model             = new XF.Model.Base_Course();
                model.CourseID    = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColID.Name].Value);
                model.CourseName  = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColName.Name].Value);
                model.MaxCount    = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColMaxCount.Name].Value);
                model.MaxSection  = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColMaxSection.Name].Value);
                model.Color       = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColColor.Name].Value);
                model.Description = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColDescription.Name].Value);
                if (bll.Update(model))
                {
                    successRowIndex.Add(index);
                }
                else
                {
                    result += MessageText.SQL_ERROR_UPDATE + MessageText.KEY_ENTER;
                }
            }
            foreach (int rowIndex in successRowIndex)
            {
                lstUpdate.Remove(rowIndex);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <returns></returns>
        private string AddData()
        {
            string     result          = string.Empty;
            List <int> successRowIndex = new List <int>();

            XF.Model.Base_Course model;
            foreach (int index in lstInsert)
            {
                model             = new XF.Model.Base_Course();
                model.CourseName  = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColName.Name].Value);
                model.MaxCount    = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColMaxCount.Name].Value);
                model.MaxSection  = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColMaxSection.Name].Value);
                model.Color       = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColColor.Name].Value);
                model.Description = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColDescription.Name].Value);
                int ret = bll.Add(model);
                if (ret == PhysicalConstants.SQL_Existed)
                {
                    result += string.Format(MessageText.SQL_ERROR_COURSE_EXIST, index + 1) + MessageText.KEY_ENTER;
                }
                else
                {
                    xfDataGridView1.Rows[index].Cells[ColID.Name].Value = ret;
                    successRowIndex.Add(index);
                }
            }
            foreach (int rowIndex in successRowIndex)
            {
                lstInsert.Remove(rowIndex);
            }
            return(result);
        }