Esempio n. 1
0
        public static void AddItem()
        {
            var dialog          = new AddForm();
            var dialogPresenter = new AddPresenter(dialog, repository);

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                programView.UpdateList(repository.GetAllTasks());
            }
        }
Esempio n. 2
0
        //Event handler
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddForm addForm = new AddForm(coffeeFlavorList);

            addForm.ShowDialog();
            CoffeeFlavor tempFlavor = addForm.getFlavor();

            if (tempFlavor != null)
            {
                addCoffeeFlavorsToList(tempFlavor);
            }
        }
Esempio n. 3
0
        //public Form createForm()
        //{
        //    throw new NotImplementedException();
        //}

        //public Form createForm(IConnector dbConn, string dbName, string tabName)
        //{
        //    throw new NotImplementedException();
        //}

        public Form createForm(IConnector dbConn, string dbName, string tabName, string windowsName, object[] obj)
        {
            BaseForm frm = new AddForm(dbConn, dbName, tabName, windowsName, obj);

            frm.ShowDialog();
            return(frm);

            //FormAddFactoryBuilder builder = new FormAddFactoryBuilder();
            //builder.SetConnectot(dbConn);
            //BaseForm frm = builder.build();
            //frm.ShowDialog();
            //return frm;
        }
Esempio n. 4
0
 private void Button_Click_6(object sender, RoutedEventArgs e)
 {
     try
     {
         string     firstSelectedCellContent = ((TextBlock)(this.DgridMedicament.Columns[0].GetCellContent(DgridMedicament.SelectedItem))).Text;
         MEDICAMENT name     = dbContext.MEDICAMENTs.First(m => m.M_NAME == firstSelectedCellContent);
         AddForm    editForm = new AddForm(name, this);
         editForm.Show();
     }
     catch (Exception)
     {
         MessageBox.Show("Выделите строку, которую хотите редактировать");
     }
 }
Esempio n. 5
0
        public IActionResult Privacy(AddForm add)
        {
            Techlist techlist = new Techlist
            {
                Category     = add.Category,
                Manufacturer = add.Manufacturer,
                Model        = add.Model,
                Photo        = "img/5.png"
            };

            db.Techlist.Add(techlist);
            db.SaveChanges();
            return(RedirectToAction("Privacy"));
        }
Esempio n. 6
0
        private void cM_add_Click(object sender, EventArgs e)
        {
            AddForm newForm = new AddForm();

            if (newForm.ShowDialog(this) == DialogResult.OK)
            {
                var selNode = trV_main.SelectedNode;
                if (selNode != null)
                {
                    newForm.NewUser.ContextMenuStrip = cM_edit_delete;
                    selNode?.Nodes.Add(newForm.NewUser);
                }
            }
        }
Esempio n. 7
0
            private void GlobalKeyUp(object sender, KeyEventArgs e)
            {
                // update form
                foreach (Control c in AddForm.Controls)
                {
                    c.Enabled = true;
                }
                AddForm.button6.Enabled = true;
                AddForm.DrawKeyDisplay();
                AddForm.TextBoxKeyCombo.Select(AddForm.TextBoxKeyCombo.Text.Length, 0);

                // remove hook
                HookManager.CleanHook();
            }
Esempio n. 8
0
 private void MenuItem_Click_3(object sender, RoutedEventArgs e)
 {
     try
     {
         var firstSelectedCellContent = ((TextBlock)(this.DgridMedicament.Columns[0].GetCellContent(DgridMedicament.SelectedItem))).Text;
         var name     = dbContext.MEDICAMENTs.First(m => m.M_NAME == firstSelectedCellContent);
         var editForm = new AddForm(name, this);
         editForm.Show();
     }
     catch (Exception)
     {
         MessageBox.Show("Выделите объект, который хотите редактировать");
     }
 }
Esempio n. 9
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //LibraryForm libraryForm = new LibraryForm();
            MainModel         mainModel         = new MainModel();
            EditForm          editForm          = new EditForm();
            Authorization     authorization     = new Authorization();
            LibraryForm       libraryForm       = new LibraryForm(mainModel);
            AddForm           addForm           = new AddForm();
            ControllerLibrary controllerLibrary = new ControllerLibrary(mainModel, libraryForm, editForm, authorization, addForm);

            Application.Run(authorization);
        }
Esempio n. 10
0
 private void DgridMedicament_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (MainWindow.access == "Администратор")
     {
         try
         {
             var firstSelectedCellContent = ((TextBlock)(this.DgridMedicament.Columns[0].GetCellContent(DgridMedicament.SelectedItem))).Text;
             var name     = dbContext.MEDICAMENTs.First(m => m.M_NAME == firstSelectedCellContent);
             var editForm = new AddForm(name, this);
             editForm.Show();
         }
         catch (Exception)
         {
             MessageBox.Show("Выделите объект, который хотите редактировать");
         }
     }
 }
Esempio n. 11
0
        public JsonResult AddPost(string orderstr)
        {
            AddForm form = JsonConvert.DeserializeObject <AddForm>(orderstr);
            var     ri   = new ResultInfo {
                State = 1
            };

            try
            {
                _thisBLL.Add(form);
            }
            catch (Exception e)
            {
                ri.State = 0;
                ri.Msg   = e.Message;
            }

            return(Json(ri, JsonRequestBehavior.AllowGet));
        }
Esempio n. 12
0
        public JsonResult Add(AddForm form)
        {
            AdvertEntity advert = new AdvertEntity()
            {
                Title        = form.Title,
                Desсription  = form.Desсription,
                UserId       = (int)Session["UserId"],
                CategoryList = _categoryRepository.GetList()
            };

            _advertRepository.Add(advert);

            int advertId = advert.Id;

            return(Json(new
            {
                IsSuccess = true,
                AdvertId = advertId
            }));
        }
Esempio n. 13
0
 private void GlobalKeyDown(object sender, KeyEventArgs e)
 {
     string[] parts = DefaultKeyAction.GetKeyCombo(Keys, true).Split('+');
     if (parts.Where(p => p == PrettyKeys.Convert(e.KeyCode)).Any())
     {
         return;                                                             // dont allow duplicate keys in the combo
     }
     if (parts.Length < DefaultKeyAction.KEY_COUNT)
     {
         for (int i = 0; i < Keys.Length; i++)
         {
             if (Keys[i] == System.Windows.Forms.Keys.None)
             {
                 Keys[i] = e.KeyCode;
                 break;
             }
         }
     }
     AddForm.DrawKeyDisplay();
 }
Esempio n. 14
0
        public ViewControl(string viewName, int maxHeight)
        {
            InitializeComponent();
            this.gridView.Name = this.viewName = viewName;
            this.Edit.Text     = "...";
            this.Edit.Width    = 30;
            this.Edit.UseColumnTextForButtonValue = true;
            view    = Program.Context.ViewToGridManager.bindToView(gridView);
            addForm = FormFactory.createAddForm(viewName, this);
            addForm.StartPosition    = FormStartPosition.CenterParent;
            updateForm               = FormFactory.createUpdateForm(viewName, this);
            updateForm.StartPosition = FormStartPosition.CenterParent;
            this.gridView.Height     = maxHeight - 50;
            if (view.Insertable == false)
            {
                this.Add.Visible = false;
            }
            if (view.Updateable == false)
            {
                this.Edit.Visible = false;
            }
//            this.
        }
Esempio n. 15
0
 public AddFridgeForm(AddForm form)
 {
     InitializeComponent();
 }
        private void Init()
        {
            //form
            Width  = 1300;
            Height = 700;
            Font   = new System.Drawing.Font("Arial", 10);
            Name   = EntityData.Name + "_Form";
            Text   = @"" + EntityData.Name + " Form";

            //components
            BtnFilterPagination.Click += (o, e) =>
            {
                try
                {
                    Offset = int.Parse(InputOffset.Text);
                    Limit  = int.Parse(InputLimit.Text);
                    Navigate(Offset, Limit);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Input tidak valid", "Error");
                    CustomConsole.WriteLine(ex.Message);
                    return;
                }
            };

            Button ClearBtn = new Button()
            {
                Text = "Clear"
            };

            ClearBtn.Click += new EventHandler((o, e) =>
            {
                EntityData.FilterParmas.Clear();
                Navigate(0, 0);
            });

            Control[] FilterControls =
            {
                new Label()
                {
                    Text = "Page(from 0)"
                }, InputOffset,
                new Label()
                {
                    Text = "Record Per Page"
                }, InputLimit,
                BtnFilterPagination, InfoOffsetLimit, new Label()
                {
                    Text = "Filter Info:"
                },
                InfoFilter, new BlankControl()
                {
                    Reserved = ReservedFor.BEFORE_HOR
                },
                new BlankControl()
                {
                    Reserved = ReservedFor.BEFORE_HOR
                },
                ClearBtn
            };
            Panel PagingPanel = ControlUtil.GeneratePanel(6, FilterControls, 0, 110, 30, Color.Azure);

            Controls.Add(PagingPanel);

            Button BtnAdd = new Button()
            {
                Text = "ADD"
            };

            BtnAdd.Click += (o, e) =>
            {
                addForm = new AddForm(EntityData.ShowAddForm(), EntityData);
                addForm.Show();
            };

            MiscPanel = ControlUtil.GeneratePanel(3, new Control[]
            {
                new TitleLabel(13)
                {
                    Text = "Buttons Panel"
                }, BtnAdd
            }, 5, 130, 20, Color.Azure, 850, 10);

            Controls.Add(MiscPanel);

            DetailPanel.SetBounds(850, 130, Constant.DETAIL_PANEL_HEIGHT, Constant.DETAIL_PANEL_WIDTH);
            DetailPanel.AutoScroll             = false;
            DetailPanel.VerticalScroll.Visible = true;
            DetailPanel.VerticalScroll.Enabled = true;
            DetailPanel.AutoScroll             = true;
            Controls.Add(DetailPanel);

            GenerateTable();
        }
Esempio n. 17
0
 private void созданиеToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var form = new AddForm<DoctorDetail>(DIKernel) { MdiParent = this };
     form.InitializeForm();
     form.Show();
 }
Esempio n. 18
0
        private void новыйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var editForm = new AddForm<ParameterDetail>(DIKernel, -1) { MdiParent = this };

            editForm.InitializeForm();
            editForm.Show();
        }
Esempio n. 19
0
        /*public class MainInfo
         * {
         *  public int Id { get; set; }
         *
         *  public string Number { get; set; }
         *
         *  public ComboBox Status { get; set; }
         *
         *  public string Product_name { get; set; }
         *
         *  public string Type { get; set; }
         *
         *  public string Vessel_name { get; set; }
         *
         *  public string Reg_number { get; set; }
         *
         *  public DateTime Plan_date { get; set; }
         *
         *  public DateTime Fact_date { get; set; }
         *
         * }*/

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            AddForm addForm = new AddForm();

            addForm.Show();
        }
Esempio n. 20
0
 public ControllerLibrary(MainModel model, LibraryForm libraryForm, EditForm edit, Authorization authorizationForm, AddForm addForm)
 {
     this.model             = model ?? throw new ArgumentNullException(nameof(model));
     this.libraryForm       = libraryForm ?? throw new ArgumentNullException(nameof(libraryForm));
     this.edit              = edit ?? throw new ArgumentNullException(nameof(edit));
     this.authorizationForm = authorizationForm ?? throw new ArgumentNullException(nameof(authorizationForm));
     this.addForm           = addForm ?? throw new ArgumentNullException(nameof(addForm));
     this.libraryForm.setController(this);
     this.edit.setController(this);
     this.authorizationForm.setController(this);
     this.addForm.setController(this);
 }
Esempio n. 21
0
        private void Button1OnClick(object sender, EventArgs e)
        {
            AddForm control = new AddForm();

            control.ShowDialog(this);
        }
Esempio n. 22
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddForm addForm = new AddForm();

            addForm.Show();
        }
Esempio n. 23
0
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            var addForm = new AddForm(null, this);

            addForm.Show();
        }
Esempio n. 24
0
            //开台
            private bool OpenTableAndAddBill(string tableno)
            {
                //打开开台、单据录入窗口
                AddForm addfrm = new AddForm();
                addfrm.Text = "开台/新建单据";
                addfrm.frmmode = 1;
                addfrm.GetConsumeBillTypeList(); //开台新建单据只允许添加消费单据
                addfrm.Label6.Text = addfrm.BillTypeList[0].ToString();
                addfrm.CurrentBillTypeName = addfrm.BillTypeList[0].ToString();
                addfrm.Label5.Text = "请为 " + tableno + " 号桌台开台并添加消费单据";
                addfrm.TextBox2.Text = rms_var.opinfo.OpID;

                addfrm.ShowDialog();
                if (addfrm.DialogResult == DialogResult.OK)
                {
                    rms_var.ExeOpenTable(tableno, int.Parse(addfrm.TextBox3.Text), addfrm.TextBox2.Text);
                    string serialno;
                    serialno = rms_var.GenUniqueCode();
                    rms_var.AddBalanceTable(serialno, tableno, addfrm.TextBox3.Text, addfrm.TextBox2.Text);
                    GetTableList(CurrentTableTypeName);
                    //准备添加第一张单据
                    if (! rms_var.SameBillinSale(addfrm.TextBox1.Text, addfrm.CurrentBillTypeName))
                    {
                        if (rms_var.AddSaleBill(serialno, tableno, addfrm.TextBox1.Text, rms_var.GetBillTypeCode(addfrm.CurrentBillTypeName), addfrm.TextBox2.Text))
                        {
                            CurrentTableNo = tableno;
                            CurrentBillNo = addfrm.TextBox1.Text;
                            CurrentBillTypename = addfrm.CurrentBillTypeName;
                        }
                        else
                        {
                            MessageBox.Show("加单操作失败!已分配的单据号可能已被其他客户端抢先使用,请重新执行加单操作。");
                        }
                    }
                    else
                    {
                        MessageBox.Show("开台已成功但加单失败(存在同号单据),请手动执行加单操作。");
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }
Esempio n. 25
0
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            var addForm = new AddForm(null, this);

            addForm.Show();
        }
Esempio n. 26
0
        public bool AddProduct(DataRow[] dr, bool isBarcode, string barcode)
        {
            bool next = false;


            float kg = -1;

            if (isBarcode && dr.Length == 0)
            {
                //object[] obj = getProductWithMassa(barcode);
                //dr = (DataRow[])obj[0];
                //kg = (float)obj[1];
                dr = getProductWithMassa(barcode);
            }

            if (dr.Length != 0)
            {
                DataSetTpos.productRow drP = (DataSetTpos.productRow)dr[0];
                DataRow[] existRows        = DBclass.DS.orders.Select("expenseId=-1 and prodId = " + drP.productId);
                if (existRows.Length > 0)
                {
                    DataSetTpos.ordersRow ordrow = (DataSetTpos.ordersRow)existRows[0];
                    ordrow.packCount = ordrow.packCount + (drP.pack == 0 ? 1 : drP.pack);
                    DataRow drOrder = ordrow;
                    drOrder["sumProduct"] = ordrow.packCount * drP.price / (drP.pack == 0 ? 1 : drP.pack);//ordrow.AcceptChanges();
                }
                else
                {
                    DataSetTpos.ordersRow ordrow = DBclass.DS.orders.NewordersRow();



                    ordrow.prodId = drP.productId;
                    if (drP.pack == 0)
                    {
                        drP.pack = 1;
                    }
                    ordrow.expenseId = -1;
                    int       curPrice = drP.price;
                    OrderForm oform    = new OrderForm(drP);
                    System.Windows.Forms.DialogResult result = oform.ShowDialog();
                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        ordrow.packCount = (float)oform.count;
                        DataRow drOrder = ordrow;
                        drOrder["sumProduct"] = oform.sum;//ordrow.packCount * drP.price / (drP.pack == 0 ? 1 : drP.pack);
                        ordrow.orderSumm      = Convert.ToSingle(drOrder["sumProduct"]);

                        //grid.Rows[e.RowIndex].Cells["sumProduct"].Value = (Convert.ToInt32(grid.Rows[e.RowIndex].Cells["packCount"].Value) * Convert.ToInt32(grid.Rows[e.RowIndex].Cells["productPrice"].Value)).ToString();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        //ordrow.RejectChanges();
                        drP.RejectChanges();
                        return(false);
                    }
                    else
                    {
                        if (drP.price == 0)
                        {
                            System.Windows.Forms.MessageBox.Show("Товар на складе отсутствует");
                            drP.RejectChanges();
                        }
                        return(false);
                    }
                    DBclass.DS.orders.AddordersRow(ordrow);
                    if (curPrice != drP.price && drP.price != 0)
                    {
                        productTableAdapter prda = new productTableAdapter();
                        prda.Update(drP);
                        return(true);
                    }
                }
                if (isNewExpense)
                {
                    //dgvExpense.Columns["productName"].Visible = true;
                    //dgvExpense.Columns["productPrice"].Visible = true;
                    isNewExpense = false;
                }
                //sumTable();
            }
            else if (isBarcode && UserValues.role == "admin")
            {
                AddForm addForm = new AddForm(barcode);
                if (addForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //productTableAdapter daProduct = new productTableAdapter();
                    //daProduct.Fill(DBclass.DS.product);
                }
            }

            next = true;
            return(true);
        }
Esempio n. 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.CheckPage()) return;
                service.Open();
                Dictionary<Question, AnswerMapTitle> questionSV = service.getQuestion(this.page);
                AddForm form = new AddForm("panel-body");
                ViewState["Page"] = this.page;
                int i = 1;
                int questionId = 0;
                StringBuilder strSeq = new StringBuilder();
                if (Session["answer"] != null)
                {
                    sess = Session["answer"] as Dictionary<string, string>;
                }

                if (questionSV.Count > 0)
                {
                    if (questionSV.First().Key.Seq <= 33)
                    {
                        Label1.Text = "ส่วนที่ 1 : ชุดคำถามหลัก";
                    }
                    else
                    {
                        Label1.Text = "ส่วนที่ 2: ชุดคำถามเพิ่มเติม";
                    }
                }
                foreach (KeyValuePair<Question, AnswerMapTitle> q in questionSV)
                {
                    Question question = q.Key;
                    AnswerMapTitle map = q.Value;
                    string remark = "";
                    if (q.Value.remark != null)
                    {
                        remark = "<div class='panel panel-primary'>"
                                      + "<div class='panel-body'>"
                                      + "<div class='row'>"
                                      + "<div class='col-sm-1'>"
                                      + "<div style='font-weight:bold;'>หมายเหตุ</div>"
                                      + "</div>"
                                      + "<div class='col-sm-11'>"
                                      + q.Value.remark.RemarkDetail
                                      + "</div></div></div></div>";
                    }
                    if (!question.Type.Equals("SLIDE") && !question.Type.Equals("TABLESEQUENE"))
                    {
                        if (q.Value.remark != null)
                        {
                            if (q.Value.remark.UpDown.ToString().Equals("Y"))
                            {
                                form.Controls.Add(new LiteralControl(remark));
                            }
                        }
                        if (question.QuestionId == 22)
                        {
                            foreach (var isess in sess)
                            {
                                if (isess.Key.ToUpper().IndexOf("QPROD1_C") != -1)
                                {
                                    if (!string.IsNullOrEmpty(isess.Value))
                                    {
                                        if (Convert.ToInt32(isess.Value) > 0)
                                        {
                                            question.Visible = "Y";
                                        }
                                    }
                                }
                            }
                        }
                        if (question.QuestionId == 1046 || question.QuestionId == 1047 || question.QuestionId == 1048 || question.QuestionId == 1049)
                        {
                            if (sess.ContainsKey("Qprod1_b_18") || sess.ContainsKey("Qprod1_b_19"))
                            {
                                question.Visible = "Y";
                            }
                        }

                        form.Controls.Add(new LiteralControl("<div id='num-" + question.QuestionId + "' class='num-cl' type-div='" + question.Type + "'" + (question.Visible.Equals("Y") ? "" : "style='display:none;'") + ">"));
                        form.Controls.Add(new LiteralControl("<label>" + question.Seq + ". " + question.QuestionName + "</label>"));
                        if(!string.IsNullOrEmpty(remark))
                        {
                            if (q.Value.remark.UpDown.ToString().Equals("N"))
                            {
                                form.Controls.Add(new LiteralControl(remark));
                            }
                        }
                    }
                    strSeq.Append(question.Seq).Append(",");
                    List<ListItem> listItem = new List<ListItem>();
                    int cntVal = map.ListAns.Length;
                    if (question.Type.Equals("CHECKBOX"))
                    {
                        HiddenField hid = new HiddenField();
                        hid.Value = question.No;
                        form.Controls.Add(hid);
                        foreach (Answer ans in map.ListAns)
                        {
                            if (string.IsNullOrEmpty(ans.Script))
                            {
                                form.AddCheckbox(ans.AnswerName, ans.Point.ToString(), ans.SubAnswer, getValueSessCheckbox(ans));
                            }
                            else
                            {
                                form.AddCheckbox(ans.AnswerName, ans.Point.ToString(), ans.SubAnswer, ans.Script, getValueSessCheckbox(ans));
                            }
                        }
                    }
                    else if (question.Type.Equals("RADIO"))
                    {
                        foreach (Answer ans in map.ListAns)
                        {
                            form.AddRadio(ans.AnswerName, ans.VarId);
                        }
                    }
                    else if (question.Type.Equals("RADIOLIST"))
                    {
                        int j = 1;
                        string index = "";
                        foreach (Answer ans in map.ListAns)
                        {
                            ListItem Litem = new ListItem();
                            if (ans.SubAnswer != null)
                            {
                                switch (ans.SubAnswer.SubAnswerType)
                                {
                                    case "TEXTBOX":
                                        string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                        string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                        Litem.Text = ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "'name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "> )";
                                        break;
                                }
                            }
                            else
                            {
                                Litem.Text = ans.AnswerName;
                            }

                            Litem.Value = ans.Point.ToString();
                            listItem.Add(Litem);
                            if (sess.ContainsKey(ans.VarId))
                            {
                                if(!string.IsNullOrEmpty(sess[ans.VarId]))
                                {
                                    if(Convert.ToInt32(sess[ans.VarId]) == ans.Point)
                                    {
                                        index = (j - 1).ToString();
                                    }
                                }

                            }
                            if (cntVal == j)
                            {
                                if (string.IsNullOrEmpty(ans.Script))
                                {
                                    form.AddRadioList(listItem, ans.VarId, index);
                                }
                                else
                                {
                                    form.AddRadioList(listItem, ans.VarId, ans.Script, index);
                                }
                            }
                            j++;
                        }
                    }
                    else if (question.Type.Equals("TEXTBOX"))
                    {
                        foreach (Answer ans in map.ListAns)
                        {
                            string valtext = "";
                            if (sess.ContainsKey(ans.VarId))
                            {
                                valtext = sess[ans.VarId].ToString();
                            }
                            if (string.IsNullOrEmpty(ans.Script))
                            {
                                form.AddTextbox(ans.VarId, ans.CssClass, valtext);
                            }
                            else
                            {
                                form.AddTextbox(ans.VarId, ans.CssClass, ans.Script, valtext);
                            }
                        }
                    }
                    else if (question.Type.Equals("DROPDOWNANDRADIOLIST"))
                    {
                        int j = 1;
                        string index = "";
                        foreach (Answer ans in map.ListAns)
                        {
                            if (ans.AnswerType.Equals("DROPDOWN"))
                            {
                                Item[] dropdown = service.getDropdown(ans.AnswerName);
                                string selected = "";
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    int k = 0;
                                    foreach (Item it in dropdown)
                                    {
                                        if (it.value.Equals(sess[ans.VarId]))
                                        {
                                            selected = k.ToString();
                                        }
                                        k++;
                                    }
                                }
                                form.AddDropDown(dropdown, "col-sm-3", ans.Script, selected);
                            }
                            else
                            {
                                int p = 0;
                                ListItem item = new ListItem();
                                item.Text = ans.AnswerName;
                                item.Value = ans.Point.ToString();
                                listItem.Add(item);
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    if (!string.IsNullOrEmpty(sess[ans.VarId]))
                                    {
                                        if (Convert.ToInt32(sess[ans.VarId]) == ans.Point)
                                        {
                                            index = p.ToString();
                                        }
                                    }

                                }
                                p++;
                                if (cntVal == j)
                                {
                                    if (string.IsNullOrEmpty(ans.Script))
                                    {
                                        form.AddRadioList(listItem, ans.VarId, index);
                                    }
                                    else
                                    {
                                        form.AddRadioList(listItem, ans.VarId, ans.Script, index);
                                    }
                                }
                            }
                            j++;
                        }
                    }
                    else if (question.Type.Equals("TEXTBOXANDRADIOLIST"))
                    {
                        int j = 1;
                        string index = "";
                        int k = 0;
                        foreach (Answer ans in map.ListAns)
                        {
                            if (ans.AnswerType.Equals("TEXTBOX"))
                            {
                                string valtext = "";
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    valtext = sess[ans.VarId].ToString();
                                }
                                if (string.IsNullOrEmpty(ans.Script))
                                {
                                    form.AddTextbox(ans.VarId, ans.CssClass, valtext);
                                }
                                else
                                {
                                    form.AddTextbox(ans.VarId, ans.CssClass, ans.Script, valtext);
                                }
                            }
                            else
                            {
                                ListItem item = new ListItem();
                                item.Text = ans.AnswerName;
                                item.Value = ans.Point.ToString();
                                listItem.Add(item);
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    if (!string.IsNullOrEmpty(sess[ans.VarId]))
                                    {
                                        if (Convert.ToInt32(sess[ans.VarId]) == ans.Point)
                                        {
                                            index = k.ToString();
                                        }
                                    }

                                }
                                if (cntVal == j)
                                {
                                    if (string.IsNullOrEmpty(ans.Script))
                                    {
                                        form.AddRadioList(listItem, ans.VarId, index);
                                    }
                                    else
                                    {
                                        form.AddRadioList(listItem, ans.VarId, ans.Script, index);
                                    }
                                }
                                k++;
                            }
                            j++;
                        }
                    }
                    else if (question.Type.Equals("TABLE"))
                    {
                        string table = "";
                        table += "<div class='row'>";
                        table += "<div class='" + question.CssClass + "'>";
                        switch (question.QuestionId)
                        {
                            case 24:
                            case 1033:

                                table += "<table class='table table-bordered'>";
                                table += "<thead>";
                                table += "<tr>";
                                table += "<th></th>";
                                table += "<th>เห็นด้วยอย่างมาก</th>";
                                table += "<th>เห็นด้วย</th>";
                                table += "<th>ปานกลาง</th>";
                                table += "<th>ไม่เห็นด้วย</th>";
                                table += "<th>ไม่เห็นด้วยอย่างมาก</th>";
                                table += "<th align='center'>ไม่ทราบ</th>";
                                table += "</tr>";
                                table += "<tbody>";
                                foreach (Answer ans in map.ListAns)
                                {
                                    string select_1 = "", select_2 = "", select_3 = "", select_4 = "", select_5 = "", select_97 = "";
                                    if (sess.ContainsKey(ans.VarId))
                                    {
                                        if (sess[ans.VarId].ToString() != "")
                                        {
                                            if (sess[ans.VarId].ToString().Equals("1"))
                                            {
                                                select_1 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("2"))
                                            {
                                                select_2 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("3"))
                                            {
                                                select_3 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("4"))
                                            {
                                                select_4 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("5"))
                                            {
                                                select_5 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("-97"))
                                            {
                                                select_97 = "checked";
                                            }
                                        }
                                    }
                                    table += "<tr>";
                                    table += "<td class='pointer' data-name='" + ans.VarId + "'>" + ans.AnswerName + "</td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='1' " + select_1 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='2' " + select_2 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='3' " + select_3 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='4' " + select_4 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='5' " + select_5 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='-97' " + select_97 + "></td>";
                                    table += "</tr>";
                                }
                                table += "</tbody>";
                                table += "</table>";
                                break;
                            case 1027:
                            case 1028:
                                table += "<table class='table table-bordered'>";
                                table += "<thead>";
                                table += "<tr>";
                                table += "<th></th>";
                                table += "<th align='center'>ถูกต้อง</th>";
                                table += "<th align='center'>ไม่ถูกต้อง</th>";
                                table += "<th align='center'>ไม่ทราบ</th>";
                                table += "<th align='center'>ปฏิเสธการตอบ</th>";
                                table += "</tr>";
                                table += "<tbody>";
                                foreach (Answer ans in map.ListAns)
                                {
                                    string select_1 = "", select_0 = "", select_97 = "", select_99 = "";
                                    if (sess.ContainsKey(ans.VarId))
                                    {
                                        if (sess[ans.VarId].ToString() != "")
                                        {
                                            if (sess[ans.VarId].ToString().Equals("1"))
                                            {
                                                select_1 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("0"))
                                            {
                                                select_0 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("-97"))
                                            {
                                                select_97 = "checked";
                                            }
                                            else if (sess[ans.VarId].ToString().Equals("-99"))
                                            {
                                                select_99 = "checked";
                                            }
                                        }
                                    }
                                    table += "<tr>";
                                    table += "<td class='pointer' data-name='" + ans.VarId + "'>" + ans.AnswerName + "</td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='1' " + select_1 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='0' " + select_0 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='-97' " + select_97 + "></td>";
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='-99' " + select_99 + "></td>";
                                    table += "</tr>";
                                }
                                table += "</tbody>";
                                table += "</table>";
                                break;
                        }
                        table += "</div>";
                        table += "</div>";
                        form.Controls.Add(new LiteralControl(table));
                    }
                    else if (question.Type.Equals("YESORNO"))
                    {
                        string table = "";
                        table += "<div class='row'>";
                        table += "<div class='" + question.CssClass + "'>";
                        table += "<table class='table table-bordered'>";
                        table += "<thead>";
                        table += "<tr>";
                        table += "<th style='width:70px;text-align:center;'>ใช่/ไม่ใช่</th>";
                        table += "<th></th>";
                        table += "</tr>";
                        table += "</thead>";
                        table += "<tbody>";
                        int j = 0;
                        if (map.ListTitle.Length > 0)
                        {
                            Dictionary<TitleAnswer, List<Answer>> tmp = arrTitleAnswer(map);
                            foreach (var item in tmp)
                            {
                                table += "<tr><th></th><th colspan='2'>" + item.Key.TiTleName + "</th></tr>";
                                foreach (Answer ans in item.Value)
                                {
                                    table += "<tr class='pointer' data-name='" + ans.VarId + "' data-num='" + ans.QuestionId + "'>";
                                    string check = "";
                                    if (sess.ContainsKey(ans.VarId))
                                    {
                                        if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                        {
                                            check = "checked";
                                        }
                                    }
                                    table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + "></td>";
                                    if (ans.SubAnswer != null)
                                    {
                                        string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                        string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                        table += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "> )</td>";
                                    }
                                    else
                                    {
                                        table += "<td>" + ans.AnswerName + "</td>";
                                    }
                                    table += "</tr>";
                                    j++;
                                }
                            }
                        }
                        else
                        {
                            foreach (Answer ans in map.ListAns)
                            {
                                table += "<tr class='pointer' data-name='" + ans.VarId + "'>";
                                string check = "";
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                    {
                                        check = "checked";
                                    }
                                }
                                table += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + "></td>";
                                if (ans.SubAnswer != null)
                                {
                                    string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                    string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                    table += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                }
                                else
                                {
                                    table += "<td>" + ans.AnswerName + "</td>";
                                }
                                table += "</tr>";
                            }
                        }

                        table += "</tbody>";
                        table += "</table>";
                        table += "</div>";
                        table += "</div>";
                        form.Controls.Add(new LiteralControl(table));
                    }
                    else if (question.Type.Equals("SLIDE"))
                    {
                        Dictionary<string, int> quesionNameForSlideDefault = new Dictionary<string, int>();
                        string str = "";
                        str += "<div class='row' id='row-slide'>";
                        str += "<div id='num-" + question.QuestionId + "' class='num-cl' type-div='" + question.Type + "'" + (question.Visible.Equals("Y") ? "" : "style='display:none;") + "'>";
                        str += "<div class='" + question.CssClass + "'>";
                        str += "<div id='slider' class='form'>";
                        str += remark;
                        str += "<div data-id='slider" + question.QuestionId + "'>";
                        str += "<label>" + question.Seq + ". " + question.QuestionName + "</label>";
                        str += "<table class='table table-bordered'>";
                        str += "<thead><tr>";
                        str += "<th style='width:70px;text-align:center;'>ใช่/ไม่ใช่</th>";
                        str += "<th></th>";
                        str += "</tr></thead>";
                        str += "<tbody>";
                        foreach (Answer ans in map.ListAns)
                        {
                            string check = "";
                            if (question.QuestionId == 1051 || question.QuestionId == 1052 || question.QuestionId == 1053)
                            {
                                if (sess.ContainsKey("Qprod1_a_" + ans.Seq))
                                {
                                    if (!sess["Qprod1_a_" + ans.Seq].ToString().Equals("0"))
                                    {
                                        str += "<tr class='pointer' data-name='" + ans.VarId + "' data-num='" + ans.QuestionId + "'>";
                                        if (sess.ContainsKey(ans.VarId))
                                        {
                                            if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                            {
                                                check = "checked";
                                            }
                                        }
                                        str += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + " ></td>";
                                        if (ans.SubAnswer != null)
                                        {
                                            string valsub = (sess.ContainsKey("Qprod1_a_20_txt")) ? sess["Qprod1_a_20_txt"] : "";
                                            valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : valsub;
                                            string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                            str += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                        }
                                        else
                                        {
                                            str += "<td>" + ans.AnswerName + "</td>";
                                        }
                                        str += "</tr>";
                                    }
                                }
                                else
                                {
                                    if (ans.Point == -98)
                                    {
                                        str += "<tr class='pointer' data-name='" + ans.VarId + "' data-num='" + ans.QuestionId + "'>";
                                        if (sess.ContainsKey(ans.VarId))
                                        {
                                            if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                            {
                                                check = "checked";
                                            }
                                        }
                                        str += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + "></td>";
                                        if (ans.SubAnswer != null)
                                        {
                                            string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                            string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                            str += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                        }
                                        else
                                        {
                                            str += "<td>" + ans.AnswerName + "</td>";
                                        }
                                        str += "</tr>";
                                    }
                                }
                            }
                            else
                            {
                                str += "<tr class='pointer' data-name='" + ans.VarId + "' data-num='" + ans.QuestionId + "'>";
                                if (sess.ContainsKey(ans.VarId))
                                {
                                    if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                    {
                                        check = "checked";
                                    }
                                }
                                str += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + "></td>";
                                if (ans.SubAnswer != null)
                                {
                                    string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                    string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                    str += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "'name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                }
                                else
                                {
                                    str += "<td>" + ans.AnswerName + "</td>";
                                }
                                str += "</tr>";
                            }
                        }
                        str += "</tbody>";
                        str += "</table>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        form.Controls.Add(new LiteralControl(str));
                    }
                    else if (question.Type.Equals("TABLESEQUENE"))
                    {
                        string str = "";
                        str += "<div class='row' id='row-sequene'>";
                        str += "<div id='num-" + question.QuestionId + "' class='num-cl' type-div='" + question.Type + "'" + (question.Visible.Equals("Y") ? "" : "style='display:none;") + "'>";
                        str += "<div class='" + question.CssClass + "'>";
                        str += "<div id='slider' class='form'>";
                        str += "<div data-id='slider" + question.QuestionId + "'>";
                        str += "<label>" + question.Seq + ". " + question.QuestionName + "</label>";
                        str += "<table class='table table-bordered'>";
                        str += "<thead><tr>";
                        str += "<th style='width:70px;text-align:center;'>ใช่/ไม่ใช่</th>";
                        str += "<th></th>";
                        str += "</tr></thead>";
                        str += "<tbody>";
                        if (question.QuestionId == 1040)
                        {
                            Dictionary<TitleAnswer, List<Answer>> tmp = arrTitleAnswer(map);
                            foreach (var item in tmp)
                            {
                                str += "<tr><th></th><th colspan='2'>" + item.Key.TiTleName + "</th></tr>";
                                foreach(Answer ans in item.Value)
                                {
                                    str += "<tr class='pointer' data-name='" + ans.VarId + "' data-num='" + ans.QuestionId + "'>";
                                    string check = "";
                                    if (sess.ContainsKey(ans.VarId))
                                    {
                                        if (!string.IsNullOrEmpty(sess[ans.VarId]) && sess[ans.VarId].ToString() != "0")
                                        {
                                            check = "checked";
                                        }
                                    }
                                    str += "<td align='center'><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + "></td>";
                                    if (ans.SubAnswer != null)
                                    {
                                        string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                        string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                        str += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                    }
                                    else
                                    {
                                        str += "<td>" + ans.AnswerName + "</td>";
                                    }
                                    str += "</tr>";
                                }
                            }
                        }
                        else if (question.QuestionId == 1041)
                        {
                            int check = 0;
                            foreach (var item in map.ListAns)
                            {
                                string[] x = item.VarId.Split('_');
                                if (sess.ContainsKey("QA11_" + x.Last()))
                                {
                                    if (Convert.ToInt32(sess["QA11_" + x.Last()]) == 1)
                                    {
                                        check++;
                                        if (check > 2) break;
                                    }
                                }
                            }
                            Dictionary<TitleAnswer, List<Answer>> tmp = arrTitleAnswer(map);
                            foreach (var item in tmp)
                            {
                                string tmpTitle = "<tr><th></th><th colspan='2'>" + item.Key.TiTleName + "</th></tr>";
                                string tmpStr = "";

                                foreach (Answer ans in item.Value)
                                {
                                    string[] x = ans.VarId.Split('_');
                                    if (sess.ContainsKey("QA11_" + x.Last()))
                                    {
                                        if (!string.IsNullOrEmpty(sess["QA11_" + x.Last()]))
                                        {
                                            if (Convert.ToInt32(sess["QA11_" + x.Last()]) == 1)
                                            {
                                                tmpStr += "<tr>";
                                                string select_1 = "", select_2 = "", select_3 = "";
                                                if (sess.ContainsKey(ans.VarId))
                                                {
                                                    if (sess[ans.VarId].ToString() != "0" && sess[ans.VarId].ToString() != "")
                                                    {
                                                        if (sess[ans.VarId].ToString().Equals("1"))
                                                        {
                                                            select_1 = "selected";
                                                        }
                                                        else if (sess[ans.VarId].ToString().Equals("2"))
                                                        {
                                                            select_2 = "selected";
                                                        }
                                                        else if (sess[ans.VarId].ToString().Equals("3"))
                                                        {
                                                            select_3 = "selected";
                                                        }
                                                    }
                                                }
                                                tmpStr += "<td align='center'><select onchange=selectNum('" + question.QuestionId + "',this); id='" + ans.VarId + "' name='" + ans.VarId + "'>";
                                                tmpStr += "<option value=''>-- เลือกลำดับ --</option>";
                                                tmpStr += "<option value='1' " + select_1 + ">1</option>";
                                                tmpStr += "<option value='2' " + select_2 + ">2</option>";
                                                if (check > 2) tmpStr += "<option value='3' " + select_3 + ">3</option>";
                                                tmpStr += "</select>";
                                                tmpStr += "</td>";
                                                if (ans.SubAnswer != null)
                                                {
                                                    string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                                    string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                                    tmpStr += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                                                }
                                                else
                                                {
                                                    tmpStr += "<td>" + ans.AnswerName + "</td>";
                                                }
                                                tmpStr += "</tr>";
                                            }
                                        }
                                    }
                                }
                                if (!string.IsNullOrEmpty(tmpStr))
                                {
                                    str += tmpTitle + tmpStr;
                                }
                            }
                        }
                        str += "</tbody>";
                        str += "</table>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        form.Controls.Add(new LiteralControl(str));
                    }
                    else if (question.Type.Equals("SEQUENE"))
                    {
                        string str = "";
                        str += "<div class='row'>";
                        str += "<div class='" + question.CssClass + "'>";
                        str += "<div id='slider' class='form'>";
                        str += "<div data-id='slider" + question.QuestionId + "'>";
                        str += "<table class='table table-bordered'>";
                        str += "<thead><tr>";
                        str += "<th></th>";
                        str += "<th align='center'>ลำดับ</th>";
                        str += "</tr></thead>";
                        str += "<tbody>";
                        foreach (Answer ans in map.ListAns)
                        {
                            str += "<tr>";
                            if (ans.SubAnswer != null)
                            {
                                string valsub = (sess.ContainsKey(ans.SubAnswer.SubVarId)) ? sess[ans.SubAnswer.SubVarId].ToString() : "";
                                string scriptsub = (ans.SubAnswer.Script != null) ? "onkeyup='" + ans.SubAnswer.Script + "'" : "";
                                str += "<td>" + ans.AnswerName + " (" + ans.SubAnswer.SubAnswerName + " <input type='text' id='" + ans.SubAnswer.SubVarId + "' value='" + valsub + "' name='" + ans.SubAnswer.SubVarId + "' " + scriptsub + "'> )</td>";
                            }
                            else
                            {
                                str += "<td>" + ans.AnswerName + "</td>";
                            }
                            string select_1 = "", select_2 = "", select_3 = "";
                            if (sess.ContainsKey(ans.VarId))
                            {
                                if (sess[ans.VarId].ToString() != "0" && sess[ans.VarId].ToString() != "")
                                {
                                    if (sess[ans.VarId].ToString().Equals("1"))
                                    {
                                        select_1 = "selected";
                                    }
                                    else if (sess[ans.VarId].ToString().Equals("2"))
                                    {
                                        select_2 = "selected";
                                    }
                                    else if (sess[ans.VarId].ToString().Equals("3"))
                                    {
                                        select_3 = "selected";
                                    }
                                }
                            }
                            str += "<td align='center'><select onchange=selectNum('" + question.QuestionId + "',this); id='" + ans.VarId + "' name='" + ans.VarId + "'>";
                            str += "<option value=''>-- เลือกลำดับ --</option>";
                            str += "<option value='1' " + select_1 + ">1</option>";
                            str += "<option value='2' " + select_2 + ">2</option>";
                            str += "<option value='3' " + select_3 + ">3</option>";
                            str += "</select>";
                            str += "</tr>";
                        }
                        str += "</tbody>";
                        str += "</table>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        str += "</div>";
                        form.Controls.Add(new LiteralControl(str));
                    }
                    else if (question.Type.Equals("FLOW"))
                    {
                        switch (question.QuestionId)
                        {
                            case 9:
                                HiddenField hid = new HiddenField();
                                hid.Value = question.No;
                                form.Controls.Add(hid);
                                form.Controls.Add(new LiteralControl("<div class='form-group left-15'><label>เลือกพื้นที่จังหวัดของท่าน</label>"));
                                Item[] dropdown = service.getDropdown("PROVINCEGOID");
                                string selected = "";
                                if (Session["province"] != null)
                                {
                                    int k = 0;
                                    foreach (Item it in dropdown)
                                    {
                                        if (it.value.Equals(Session["province"]))
                                        {
                                            selected = k.ToString();
                                        }
                                        k++;
                                    }
                                }
                                form.AddDropDown(dropdown, "col-sm-3", "checkFlow(9,this);", selected);
                                form.Controls.Add(new LiteralControl("</div>"));
                                string str = "";
                                str += "<div class='form-group left-15'>";
                                str += "<label>เลือกเขตที่พักอาศัยของท่าน</label>";
                                str += "<div>";
                                Dictionary<TitleAnswer, List<Answer>> tmp = arrTitleAnswer(map);
                                string district = "";
                                if (Session["district"] != null)
                                {
                                    district = Session["district"].ToString();
                                }
                                int p = 1;
                                foreach (var title in tmp)
                                {
                                    str += "<label class='radio-inline disabled'>";
                                    if (string.IsNullOrEmpty(district))
                                    {
                                        str += "<input type='radio' name='district' value='" + title.Key.Seq + "' disabled> " + title.Key.TiTleName;
                                    }
                                    else
                                    {
                                        if (district.Equals(p.ToString()))
                                        {
                                            str += "<input type='radio' name='district' value='" + title.Key.Seq + "' checked> " + title.Key.TiTleName;
                                        }
                                        else
                                        {
                                            if (district.Equals("2") || district.Equals("3"))
                                            {
                                                if (p == 2 || p == 3)
                                                {
                                                    str += "<input type='radio' name='district' value='" + title.Key.Seq + "'> " + title.Key.TiTleName;
                                                }
                                                else
                                                {
                                                    str += "<input type='radio' name='district' value='" + title.Key.Seq + "' disabled> " + title.Key.TiTleName;
                                                }
                                            }
                                            else
                                            {
                                                str += "<input type='radio' name='district' value='" + title.Key.Seq + "' disabled> " + title.Key.TiTleName;
                                            }
                                        }
                                    }
                                    p++;
                                    str += "</label>";

                                }
                                str += "</div>";
                                str += "</div>";
                                str += "<div class='form-group left-15'>";
                                str += "<label>เลือกระดับรายได้ของท่าน</label>";
                                bool chkVar = true;
                                string income = "";
                                if (sess.ContainsKey(question.No))
                                {
                                    income = sess[question.No];
                                }
                                p = 1;
                                foreach (var item in tmp)
                                {
                                    string display = "";
                                    string check = "";
                                    if (!string.IsNullOrEmpty(district))
                                    {
                                        display = (district.Equals(p.ToString())) ? "show" : "hidden";
                                        p++;
                                    }
                                    else
                                    {
                                        display = (chkVar) ? "show" : "hidden";
                                        chkVar = false;
                                    }
                                    int n = 1;
                                    foreach (Answer ans in item.Value)
                                    {
                                        str += "<div class='radio disabled left-15 " + display + "' name='" + ans.VarId + ans.TitleId + "'>";
                                        if (!string.IsNullOrEmpty(district))
                                        {
                                            check = (!string.IsNullOrEmpty(income) && display.Equals("show") && income.Equals(n.ToString())) ? "checked" : "";
                                            str += "<label><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' " + check + ">" + ans.AnswerName + "</label>";
                                        }
                                        else
                                        {
                                            str += "<label><input type='radio' id='" + ans.VarId + "' name='" + ans.VarId + "' value='" + ans.Point + "' disabled>" + ans.AnswerName + "</label>";
                                        }
                                        str += "</div>";
                                        n++;
                                    }
                                }

                                str += "</div>";
                                form.Controls.Add(new LiteralControl(str));
                                break;
                        }
                    }
                    if (!question.Type.Equals("SLIDE") && !question.Type.Equals("TABLESEQUENE"))
                    {
                        form.Controls.Add(new LiteralControl("</div>"));
                    }
                    questionId = q.Key.QuestionId;
                    i++;
                }
                int last = service.getLastQuestion();
                string button = "";
                ViewState["lastFlag"] = false;
                string percent = service.getPercentage(this.page);
                string width = (Convert.ToDouble(percent) > 5) ? percent : "5";
                if (last == questionId)
                {
                    button += "<div class='row'>";
                    button += "<div style='display:table-row;'>";
                    button += "<div class='prev-block'><input type='button' style='float:left;' value='ก่อนหน้า' class='btn btn-warning' onclick='Back(" + this.page + ");'></div>";
                    button += "<div class='progress-block'>";
                    button += "<div class='progress'>";
                    button += "<div class='progress-bar progress-bar-striped active'  aria-valuenow='" + percent + "' aria-valuemin='0' aria-valuemax='100' style='min-width: " + width + "%'>";
                    button += percent + "%";
                    button += "</div>";
                    button += "</div>";
                    button += "</div>";
                    button += "<div class='next-block'><input type='button' style='float:right;' value='ส่งคำตอบ' class='btn btn-primary' onclick='saveAnswer();'></div>";
                    button += "</div>";
                    button += "</div>";
                    ViewState["lastFlag"] = true;
                }
                else
                {
                    button += "<div class='row'>";
                    button += "<div style='display:table-row;'>";
                    button += "<div class='prev-block'>";
                    if (this.page > 1)
                    {
                        button += "<input type='button' style='float:left;' value='ก่อนหน้า' class='btn btn-warning' onclick='Back(" + this.page + ");'>";
                    }
                    button += "</div>";
                    button += "<div class='progress-block'>";
                    button += "<div class='progress'>";
                    button += "<div class='progress-bar progress-bar-striped active'  aria-valuenow='" + percent + "' aria-valuemin='0' aria-valuemax='100' style='min-width: " + width + "%'>";
                    button += percent + "%";
                    button += "</div>";
                    button += "</div>";
                    button += "</div>";
                    button += "<div class='next-block'><input type='button' style='float:right;' value='ถัดไป' class='btn btn-primary' onclick='sendAnswer(" + this.page + ");'></div>";
                    button += "</div>";
                    button += "</div>";
                }
                form.Controls.Add(new LiteralControl(button));
                PlaceHolder1.Controls.Add(form);
                if (strSeq.Length > 0)
                {
                    string s = strSeq.ToString();
                    s = s.Substring(0, s.Length - 1);
                    ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>seq = '" + s + "';\ncurrentPage = " + this.page + ";</script>");
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                service.Close();
            }
        }
Esempio n. 28
0
            //完成预定将预订桌台转为开台
            public static bool CompleteAppoint(string appointno)
            {
                if (MessageBox.Show("确定要完成选中的预定订单,并将预订的桌台状态设为使用吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                    conn.ConnectionString = ConnStr;
                    try
                    {
                        SqlCommand selectCMD = new SqlCommand();
                        selectCMD.Connection = conn;
                        conn.Open();

                        string tableno;

                        selectCMD.CommandText = "update appointbill set status='1' where appointno='" + appointno + "'";
                        selectCMD.ExecuteNonQuery();

                        selectCMD.CommandText = "select tableno from view_appointtable where appointno='" + appointno + "'";

                        SqlDataAdapter dbDA = new SqlDataAdapter();
                        dbDA.SelectCommand = selectCMD;
                        DataSet dbDS = new DataSet();
                        dbDA.Fill(dbDS, "t1");

                        //遍历所有当前预订到期的桌台
                        //同一桌台使用相同的 serialno 等同于 并台
                        string serialno;
                        serialno = GenUniqueCode();

                        for (int i = 0; i <= dbDS.Tables[0].Rows.Count - 1; i++)
                        {
                            if (GetTableStatus(dbDS.Tables[0].Rows[i][0].ToString()) == 1) //正在使用中
                            {
                                MessageBox.Show("在当前 " + DateTime.Now.ToShortDateString() + " " + GetSysSetup("CurrentTimeblockName") + " 预订到期的 " + dbDS.Tables[0].Rows[i][0] + " 号桌台正在使用,更新预订操作不能完成!");
                                return false;
                            }
                        }

                        for (int i = 0; i <= dbDS.Tables[0].Rows.Count - 1; i++)
                        {
                            tableno = dbDS.Tables[0].Rows[i][0].ToString();
                            //打开开台、单据录入窗口
                            AddForm addfrm = new AddForm();
                            addfrm.Text = "开台/新建单据";
                            addfrm.frmmode = 1;
                            addfrm.GetConsumeBillTypeList(); //开台新建单据只允许添加消费单据
                            addfrm.TextBox3.Text = GetTableMaxPeopleNumber(tableno); //返回桌台最大载客数
                            addfrm.Label6.Text = addfrm.BillTypeList[0].ToString();
                            addfrm.CurrentBillTypeName = addfrm.BillTypeList[0].ToString();
                            addfrm.Label5.Text = "请为 " + tableno + " 号桌台开台并添加消费单据";

                            addfrm.ShowDialog();
                            if (addfrm.DialogResult == DialogResult.OK)
                            {
                                ExeOpenTable(tableno, int.Parse(addfrm.TextBox3.Text), addfrm.TextBox2.Text);
                                //准备添加第一张单据
                                if (! SameBillinSale(addfrm.TextBox1.Text, addfrm.CurrentBillTypeName))
                                {

                                    AddSaleBill(serialno, tableno, addfrm.TextBox1.Text, GetBillTypeCode(addfrm.CurrentBillTypeName), addfrm.TextBox2.Text);
                                    AddBalanceTable(serialno, tableno, addfrm.TextBox3.Text, addfrm.TextBox2.Text);

                                    //遍历所有当前预订到期的订单菜品,添加到当前单据及桌台中
                                    selectCMD.CommandText = "select foodcode,price,quantity,oprandi,taste from view_appointfood where appointno='" + appointno + "'";
                                    SqlDataAdapter dbDA1 = new SqlDataAdapter();
                                    dbDA1.SelectCommand = selectCMD;
                                    DataSet dbDS1 = new DataSet();
                                    dbDA1.Fill(dbDS1, "t");

                                    for (int j = 0; j <= dbDS1.Tables[0].Rows.Count - 1; j++)
                                    {
                                        AddFoodtoBill(serialno, GenUniqueCode(), addfrm.TextBox1.Text, GetBillTypeCode(addfrm.CurrentBillTypeName), dbDS1.Tables[0].Rows[j][0].ToString(), dbDS1.Tables[0].Rows[j][1].ToString(), System.Convert.ToDouble(dbDS1.Tables[0].Rows[j][2]), 0, dbDS1.Tables[0].Rows[j][3].ToString(), dbDS1.Tables[0].Rows[j][4].ToString(), opinfo.OpID, "", 0);
                                    }

                                }
                                else
                                {
                                    MessageBox.Show("已经存在同类型的单据了");
                                }
                            }
                            else
                            {
                                return false;
                            }
                            addfrm.Dispose();
                        }

                        selectCMD.CommandText = "update appointbill set status='1' where appointno='" + appointno + "'";
                        selectCMD.ExecuteNonQuery();

                        MessageBox.Show("预订转开台操作顺利完成!");
                        return true;

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return false;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
                return false;
            }
Esempio n. 29
0
        private void cM_edit_Click(object sender, EventArgs e)
        {
            AddForm newForm = new AddForm((MyNodes)trV_main.SelectedNode);

            newForm.ShowDialog();
        }
Esempio n. 30
0
 public AddFormPresenter(Assigment1.AddForm addForm)
 {
     this.addFormView = addForm;
     viewManagerModel = new AddFormModel(this);
 }
Esempio n. 31
0
        private void AllButtons_Click(object sender, EventArgs e)
        {
            var button = (Button)sender;

            switch (button.Name)
            {
            case "startButton":
                started = true;
                SetStartVisiblity(true);
                startTimeTextBox.Text = DateTime.Now.ToString().Split(' ')[1];
                startDateTextBox.Text = DateTime.Now.ToString().Split(' ')[0];
                break;

            case "endButton":
                ended = true;
                SetEndVisiblity(true);
                endTimeTextBox.Text = DateTime.Now.ToString().Split(' ')[1];
                endDateTextBox.Text = DateTime.Now.ToString().Split(' ')[0];
                break;

            case "cancelButton":
                ended                 = false;
                started               = false;
                startPanel.Visible    = false;
                endButton.Visible     = false;
                endPanel.Visible      = false;
                confirmButton.Visible = false;
                cancelButton.Visible  = false;
                break;

            case "confirmButton":
                int daysInSeconds;
                try
                {
                    DateTime startDateTime = new DateTime(Convert.ToInt32(startDateTextBox.Text.Split('.')[2]), Convert.ToInt32(startDateTextBox.Text.Split('.')[1]), Convert.ToInt32(startDateTextBox.Text.Split('.')[0]),
                                                          Convert.ToInt32(startTimeTextBox.Text.Split(':')[0]), Convert.ToInt32(startTimeTextBox.Text.Split(':')[1]), Convert.ToInt32(startTimeTextBox.Text.Split(':')[2]));

                    DateTime endDateTime = new DateTime(Convert.ToInt32(endDateTextBox.Text.Split('.')[2]), Convert.ToInt32(endDateTextBox.Text.Split('.')[1]), Convert.ToInt32(endDateTextBox.Text.Split('.')[0]),
                                                        Convert.ToInt32(endTimeTextBox.Text.Split(':')[0]), Convert.ToInt32(endTimeTextBox.Text.Split(':')[1]), Convert.ToInt32(endTimeTextBox.Text.Split(':')[2]));

                    TimeSpan differenseDate = endDateTime - startDateTime;

                    if (differenseDate.Days > 0)
                    {
                        daysInSeconds = differenseDate.Days * 24 * 60 * 60;
                    }
                    else
                    {
                        daysInSeconds = 0;
                    }

                    string[] thisSecondsFileNames = new string[5] {
                        "TotalSeconds", "ThisYearSeconds", "ThisMonthSeconds", "ThisWeekSeconds", "TodaySeconds"
                    };

                    foreach (var fileName in thisSecondsFileNames)
                    {
                        Storage.Save(listBox.SelectedItem.ToString(), fileName, Convert.ToString(Convert.ToInt32(Storage.Load(listBox.SelectedItem.ToString(), fileName)) +
                                                                                                 (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds));
                    }

                    //totalSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisYearSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisMonthSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisWeekSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //todaySeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;

                    int    nowSeconds = (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    var    seconds    = TimeSpan.FromSeconds(nowSeconds);
                    string spent      = "";
                    if (seconds.Hours != 0)
                    {
                        spent += $"{seconds.Hours} ч. ";
                    }
                    if (seconds.Minutes != 0)
                    {
                        spent += $"{seconds.Minutes} мин. ";
                    }
                    if (seconds.Seconds != 0)
                    {
                        spent += $"{seconds.Seconds} сек.";
                    }
                    if (spent == "")
                    {
                        spent = "0 сек.";
                    }
                    string saveHistory = historyRichTextBox.Text;
                    historyRichTextBox.Text  = "";
                    historyRichTextBox.Text += $"ОТ {startDateTextBox.Text} {startTimeTextBox.Text}\n" +
                                               $"ДО {endDateTextBox.Text} {endTimeTextBox.Text}\n" +
                                               $"ПОТРАЧЕНО {spent}\n\n";
                    historyRichTextBox.Text += saveHistory;

                    TimeSpentForm timeSpentForm1 = new TimeSpentForm(listBox.SelectedItem.ToString());
                    timeSpentForm1.Close();
                }
                catch
                {
                    ended                 = true;
                    started               = true;
                    startPanel.Visible    = true;
                    endButton.Visible     = true;
                    endPanel.Visible      = true;
                    confirmButton.Visible = true;
                    cancelButton.Visible  = true;
                    break;
                }
                ended                 = false;
                started               = false;
                startPanel.Visible    = false;
                endButton.Visible     = false;
                endPanel.Visible      = false;
                confirmButton.Visible = false;
                cancelButton.Visible  = false;
                break;

            case "addButton":
                AddForm addForm = new AddForm();
                addForm.ShowDialog();
                if (addForm.AddedDirectory != null)
                {
                    ShowItemsInListBox();
                    listBox.SelectedItem = addForm.AddedDirectory;
                }
                break;

            case "deleteButton":
                if (listBox.SelectedItem != null)
                {
                    DialogResult dialogResult = MessageBox.Show($"Delete {listBox.SelectedItem} item?", "Deleting", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Storage.DeleteDirectory(listBox.SelectedItem.ToString());
                        ShowItemsInListBox();
                        savedDirectorySelection = null;
                        if (listBox.Items.Count > 0)
                        {
                            listBox.SelectedIndex = 0;
                        }
                        else
                        {
                            mainTableLayoutPanel.Visible    = false;
                            historyTableLayoutPanel.Visible = false;
                        }
                    }
                }
                break;

            case "editButton":
                if (listBox.SelectedItem != null)
                {
                    EditForm editForm = new EditForm(listBox.SelectedItem.ToString());
                    editForm.ShowDialog();

                    ShowItemsInListBox();
                    savedDirectorySelection = editForm.NewDirectoryName;
                    listBox.SelectedItem    = editForm.NewDirectoryName;
                }
                break;

            case "showSpentButton":
                TimeSpentForm timeSpentForm = new TimeSpentForm(listBox.SelectedItem.ToString());
                timeSpentForm.ShowDialog();
                timeSpentForm.Close();
                break;
            }
        }
Esempio n. 32
0
            //加单
            private void AddBill(string tableno)
            {
                //打开单据录入窗口
                AddForm addfrm = new AddForm();
                addfrm.Text = "添加单据";
                addfrm.frmmode = 0;
                //Dim tableno As String
                //tableno = dgTableStatus.Item(dgTableStatus.CurrentRowIndex, 0)
                CurrentTableNo = tableno;
                //检测当前桌台是否有消费单据
                if (rms_var.TableConsumeBillExists(tableno))
                {
                    addfrm.GetBillTypeList();
                    addfrm.Label6.Text = addfrm.BillTypeList[0].ToString();
                    addfrm.CurrentBillTypeName = addfrm.BillTypeList[0].ToString();
                }
                else
                {
                    addfrm.GetConsumeBillTypeList();
                    addfrm.Label6.Text = addfrm.BillTypeList[0].ToString();
                    addfrm.CurrentBillTypeName = addfrm.BillTypeList[0].ToString();
                }

                addfrm.TextBox3.Visible = false;
                addfrm.Label3.Visible = false;
                addfrm.Label5.Text = "请为 " + tableno + " 号桌台加单";

                addfrm.TextBox2.Text = rms_var.opinfo.OpID;
                addfrm.ShowDialog();
                if (addfrm.DialogResult == DialogResult.OK)
                {
                    //准备添加单据
                    if (! rms_var.SameBillinSale(addfrm.TextBox1.Text, addfrm.CurrentBillTypeName))
                    {
                        if (rms_var.AddSaleBill(rms_var.GetCurrentTableSerialNo(tableno), tableno, addfrm.TextBox1.Text, rms_var.GetBillTypeCode(addfrm.CurrentBillTypeName), addfrm.TextBox2.Text))
                        {
                            CurrentBillNo = addfrm.TextBox1.Text;
                            MessageBox.Show("加单操作顺利完成");
                            //刷新桌台的单据列表
                            ShowBill(CurrentTableNo, "last");
                        }
                        else
                        {
                            MessageBox.Show("加单操作失败!已分配的单据号可能已被其他客户端抢先使用,请重新执行加单操作。");
                        }
                    }
                    else
                    {
                        MessageBox.Show("加单操作失败!已经存在同号单据,请重新执行加单操作。");
                    }
                }
            }