Exemple #1
0
        private void B_LOAD_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            int success = 0;
            int fail    = 0;

            if (authenCodes != null)
            {
                if (authenCodes.Count > 0)
                {
                    int rowIndex = 0;
                    foreach (ModelAuthenCode code in authenCodes)
                    {
                        if (rowIndex > 0)
                        {
                            if (authenCodeDao.Insert(code))
                            {
                                success++;
                            }
                            else
                            {
                                fail++;
                            }
                        }
                        rowIndex++;
                    }
                    MessageBox.Show("โหลดข้อมูลทั้งหมด " + (authenCodes.Count - 1) + " สำเร็จ " + success + " ผิดพลาด " + fail);
                    refresh();
                }
            }
            Cursor = Cursors.Default;
        }
Exemple #2
0
        private void B_ADD_Click(object sender, EventArgs e)
        {
            if (isValidInputData())
            {
                int StationID = Convert.ToInt32(lounge_site.SelectedValue);

                ModelAuthenCode model = new ModelAuthenCode();
                model.id         = this.id;
                model.ath_code   = ath_code.Text;
                model.ath_use    = (ath_use.Checked) ? "1" : "0";
                model.station_id = StationID;
                Boolean result = false;
                switch (B_ADD.Text)
                {
                case "บันทึก":
                    result = authenCodeDao.Insert(model);
                    if (result)
                    {
                        MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว");
                    }
                    break;

                case "แก้ไข":
                    result = authenCodeDao.Update(model);
                    if (result)
                    {
                        MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว");
                    }
                    break;
                }
                if (result)
                {
                    refresh();
                }
            }
        }