コード例 #1
0
        public long EditSubTopic(SubTopicModel subTopicModel)
        {
            long          result = 0;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE SubTopic SET ");
            strSql.Append("SubTopicTitle=@SubTopicTitle,Material=@Material,");
            strSql.Append("ModifiedOn=@ModifiedOn,ModifiedBy=@ModifiedBy");
            strSql.Append(" where SubTopicID=@SubTopicID");

            SqlParameter[] parameters =
            {
                new SqlParameter("@SubTopicTitle", SqlDbType.NVarChar,  -1),
                new SqlParameter("@Material",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@ModifiedOn",    SqlDbType.DateTime),
                new SqlParameter("@ModifiedBy",    SqlDbType.Int),
                new SqlParameter("@SubTopicID",    SqlDbType.BigInt),
            };
            parameters[0].Value = subTopicModel.SubTopicTitle;
            parameters[1].Value = subTopicModel.Material;
            parameters[2].Value = subTopicModel.ModifiedOn;
            parameters[3].Value = subTopicModel.ModifiedBy;
            parameters[4].Value = subTopicModel.SubTopicID;

            result = DbHelper.ExecuteSql(strSql.ToString(), parameters);
            if (result > 1)
            {
                result = subTopicModel.MainTopicID;
            }
            return(result);
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            LessonPlanner lessonPlanner = new LessonPlanner();

            if (lblSubTopicID.Text == "0")           //ADD
            {
                SubTopicModel subTopicModel = new SubTopicModel();
                subTopicModel.MainTopicID     = _mainTopicID;
                subTopicModel.MainTopicNumber = txtMainTopic.Text;
                subTopicModel.SubTopicNumber  = txtSubTopicNo.Text;
                subTopicModel.SubTopicTitle   = txtTitleSubTopic.Text;
                subTopicModel.Material        = txtMaterial.Text;
                subTopicModel.CreatedOn       = DateTime.Now;
                subTopicModel.CreatedBy       = 1;
                subTopicModel.ModifiedOn      = DateTime.Now;
                subTopicModel.ModifiedBy      = 1;

                LessonPlanner.subTopicModelsListGlobal.Add(subTopicModel);

                if (LessonPlanner.subTopicModelsListGlobal != null && LessonPlanner.subTopicModelsListGlobal.Count() > 0)
                {
                    LessonPlanner lesson = (LessonPlanner)Application.OpenForms["LessonPlanner"];
                    if (lesson != null)
                    {
                        //int subTopicMaterialAdded = LessonPlanner.subTopicModelsListGlobal.Where(x => !string.IsNullOrEmpty(x.Material)).Count();
                        //if (subTopicMaterialAdded > 0)
                        //{

                        //}
                        lesson.txtMaterial.Text = "";
                    }
                }
            }
            else            //EDIT
            {
                SubTopicModel subTopicModel = new SubTopicModel();
                //subTopicModel.MainTopicID = Convert.ToInt64();
                subTopicModel.SubTopicID      = Convert.ToInt64(lblSubTopicID.Text);
                subTopicModel.MainTopicNumber = txtMainTopic.Text;
                subTopicModel.SubTopicNumber  = txtSubTopicNo.Text;
                subTopicModel.SubTopicTitle   = txtTitleSubTopic.Text;
                subTopicModel.Material        = txtMaterial.Text;
                subTopicModel.ModifiedOn      = DateTime.Now;
                subTopicModel.ModifiedBy      = 1;

                LessonPlannerRepository lessonPlannerRepository = new LessonPlannerRepository();
                long result = lessonPlannerRepository.EditSubTopic(subTopicModel);
                if (result > 0)
                {
                    ShowStatus(true, "ADD");
                }
                //SaveToDB
            }

            this.Close();
        }
コード例 #3
0
ファイル: LessonPlanner.cs プロジェクト: shzadpk2/QMLPAdmin
        private void btnSaveSubTopic_Click(object sender, EventArgs e)
        {
            if (LessonPlanner.subTopicModelsListGlobal.Count() == 26)
            {
                MessageBox.Show("Maximum SubTopic Limit Reached!", "SubTopic Limit Reached", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (string.IsNullOrEmpty(txtMainTopic.Text))
            {
                MessageBox.Show("Main Topic # can't be blank!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (string.IsNullOrEmpty(txtSubTopicNo.Text))
            {
                MessageBox.Show("Sub Topic # can't be blank!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (string.IsNullOrEmpty(txtTitleSubTopic.Text))
            {
                MessageBox.Show("Title Sub Topic can't be blank!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (string.IsNullOrEmpty(subtopicMaterial.Text))
            {
                MessageBox.Show("Sub Topic's Material can't be blank!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                SubTopicModel subTopicModel = new SubTopicModel();
                subTopicModel.MainTopicID     = Convert.ToInt64(lblMainTopicID.Text);
                subTopicModel.MainTopicNumber = txtMainTopic.Text;
                subTopicModel.SubTopicNumber  = txtSubTopicNo.Text;
                subTopicModel.SubTopicTitle   = txtTitleSubTopic.Text;
                subTopicModel.Material        = subtopicMaterial.Text;
                subTopicModel.CreatedOn       = DateTime.Now;
                subTopicModel.CreatedBy       = 1;
                subTopicModel.ModifiedOn      = DateTime.Now;
                subTopicModel.ModifiedBy      = 1;

                subTopicModelsListGlobal.Add(subTopicModel);

                if (LessonPlanner.subTopicModelsListGlobal != null && LessonPlanner.subTopicModelsListGlobal.Count() > 0)
                {
                    txtMaterial.Text     = "";
                    txtMaterial.ReadOnly = true;
                }
            }
            SetSubTopicValues();
            //pnlSubTopic.Hide();
        }
コード例 #4
0
ファイル: ViewSubTopics.cs プロジェクト: shzadpk2/QMLPUser
        private List <SubTopicModel> TranslateDataTableToSubTopicsModel(DataTable dataTable)
        {
            List <SubTopicModel> subTopicModels = new List <SubTopicModel>();

            foreach (DataRow row in dataTable.Rows)
            {
                SubTopicModel subTopicModel = new SubTopicModel();
                subTopicModel.SubTopicID      = row["SubTopicID"] != DBNull.Value ? Convert.ToInt64(row["SubTopicID"].ToString()) : 0;
                subTopicModel.SubTopicNumber  = row["SubTopicNumber"] != DBNull.Value ? Convert.ToString(row["SubTopicNumber"]) : string.Empty;
                subTopicModel.MainTopicNumber = row["MainTopicNumber"] != DBNull.Value ? Convert.ToString(row["MainTopicNumber"]) : string.Empty;
                subTopicModel.SubTopicTitle   = row["SubTopicTitle"] != DBNull.Value ? Convert.ToString(row["SubTopicTitle"]) : string.Empty;
                subTopicModel.Introduction    = row["Introduction"] != DBNull.Value ? Convert.ToString(row["Introduction"]) : string.Empty;
                subTopicModel.Objectives      = row["Objectives"] != DBNull.Value ? Convert.ToString(row["Objectives"]) : string.Empty;
                subTopicModel.Material        = row["Material"] != DBNull.Value ? Convert.ToString(row["Material"]) : string.Empty;
                subTopicModel.MainTopicID     = row["MainTopicID"] != DBNull.Value ? Convert.ToInt64(row["MainTopicID"].ToString()) : 0;

                subTopicModels.Add(subTopicModel);
            }

            return(subTopicModels);
        }
コード例 #5
0
        public SubTopic(SubTopicModel subTopicModel) ////EDIT
        {
            InitializeComponent();

            lblSubTopicID.Text = Convert.ToString(subTopicModel.SubTopicID);
        }