Exemple #1
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            //Question
            string description = txtQuestion.Text;
            string minScore    = comboMinScore.SelectedItem.ToString();
            string maxScore    = comboMaxScore.SelectedItem.ToString();
            string answer      = txtAnswer.Text;
            string createDate  = DateTime.Now.ToShortDateString();

            Entity.EvaluationQuestion evaluationQuestion = new Entity.EvaluationQuestion()
            {
                CreatedDate    = createDate,
                EvQDescription = description,
                EvQId          = "",
                StaffId        = GlobalVariable.StaffID
            };
            string json = JsonConvert.SerializeObject(evaluationQuestion);
            string url  = ApiRouting.GetUrl("", "", "evaluationQuestion", ApiFunction.Add).ToString();
            string responseInsertedId = "";
            bool   confirm            = url.Post <Entity.EvaluationQuestion>(json, ref responseInsertedId);

            if (confirm)
            {
                Entity.EvaluationQuestionDetail evaluationQuestionDetail = new EvaluationQuestionDetail()
                {
                    Answer      = answer,
                    EvQDetailId = "",
                    EvQId       = responseInsertedId,
                    EvQName     = "Unknown",
                    MaxScore    = maxScore,
                    MinScore    = minScore
                };
                url  = ApiRouting.GetUrl("", "", "evaluationQuestionDetail", ApiFunction.Add).ToString();
                json = JsonConvert.SerializeObject(evaluationQuestionDetail);
                bool deConfirm = url.Post <Entity.EvaluationQuestionDetail>(json);
                if (deConfirm)
                {
                    MessageBox.Show("Operation Successful");
                }
                var obj = Singleton.Instance.Container.Resolve <MainView>("evaluation question");
                obj.Init();
            }
        }
Exemple #2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            int    index = dataGridMain.CurrentCell.RowIndex;
            string id    = dataGridMain.Rows[index].Cells[0].Value.ToString();

            Entity.EvaluationQuestion evaluationQuestion = new Entity.EvaluationQuestion()
            {
                CreatedDate    = "",
                EvQDescription = "",
                EvQId          = id,
                StaffId        = ""
            };
            string queryString = evaluationQuestion.GetQueryString();
            string url         = ApiRouting.GetUrl("", "", "evaluationQuestion", ApiFunction.DeleteById).ToString() + queryString;
            bool   confirm     = url.Detete <Entity.EvaluationQuestion>();

            if (confirm)
            {
                Init();
                MessageBox.Show("Operation Successful");
            }
        }