Example #1
0
        private void workerSave_Dowork(object sender, DoWorkEventArgs e)
        {
            string is_greendisc = this.chkGreendisc.CheckState.ToYesOrNoString();
            string is_pinkdisc  = this.chkPinkdisc.CheckState.ToYesOrNoString();

            string json_data = "{\"id\":" + this.parent_form.serial.id.ToString() + ",";

            json_data += "\"verext\":\"" + this.verext + "\",";
            json_data += "\"is_greendisc\":\"" + is_greendisc + "\",";
            json_data += "\"is_pinkdisc\":\"" + is_pinkdisc + "\",";
            json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";

            CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/up_new_rwt_line", json_data);
            ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                this.parent_form.serial          = sr.serial[0];
                this.parent_form.problem         = sr.problem;
                this.parent_form.problem_im_only = (sr.problem.Count > 0 ? sr.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>());
                this.parent_form.verext          = sr.verext[0];
                this.save_result = true;
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                this.save_result = false;
            }
        }
Example #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.user_from == null)
            {
                MessageAlert.Show("กรุณาระบุรหัสพนักงาน จาก");
                return;
            }
            if (this.user_to == null)
            {
                MessageAlert.Show("กรุณาระบุรหัสพนักงาน ถึง");
                return;
            }
            if (this.date_from == null)
            {
                MessageAlert.Show("กรุณาระบุวันที่ จาก");
                return;
            }
            if (this.date_to == null)
            {
                MessageAlert.Show("กรุณาระบุวันที่ ถึง");
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.cloudDateFrom.Texts.Replace("/", "").Trim().Length == 0)
            {
                MessageAlert.Show("กรุณาระบุวันที่เริ่ม", "", MessageAlertButtons.OK, MessageAlertIcons.WARNING);
                this.cloudDateFrom.Focus();
                return;
            }

            if (this.cloudDateTo.Texts.Replace("/", "").Trim().Length == 0)
            {
                MessageAlert.Show("กรุณาระบุวันที่สิ้นสุด", "", MessageAlertButtons.OK, MessageAlertIcons.WARNING);
                this.cloudDateTo.Focus();
                return;
            }

            if (this.cloudEmail.Texts.Trim().Length == 0)
            {
                MessageAlert.Show("กรุณาระบุอีเมล์", "", MessageAlertButtons.OK, MessageAlertIcons.WARNING);
                this.cloudEmail.Focus();
                return;
            }

            this.SaveCloudSrv();
        }
Example #4
0
        private void showEditForm(int mac_id)
        {
            CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "macallowed/get_at&mac_id=" + mac_id.ToString());

            ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (get.result)
            {
                MacAddressEditForm editForm = new MacAddressEditForm();
                editForm.G = this.G;

                int    id          = sr.macallowed.First <MacAllowed>().id;
                string mac_address = sr.macallowed.First <MacAllowed>().mac_address;
                editForm.editing_mac_id     = id;
                editForm.txtMacAddress.Text = mac_address;
                if (editForm.ShowDialog() == DialogResult.OK)
                {
                    this.loadMacAddressData(mac_id);
                }
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
            }
        }
        private void BindingControlEvent()
        {
            #region Row hover background
            this.dgvAll.CellMouseEnter      += new DataGridViewCellEventHandler(this.SetRowHoverBackground);
            this.dgvSelected.CellMouseEnter += new DataGridViewCellEventHandler(this.SetRowHoverBackground);
            this.dgvAll.CellMouseLeave      += new DataGridViewCellEventHandler(this.SetRowLeaveBackground);
            this.dgvSelected.CellMouseLeave += new DataGridViewCellEventHandler(this.SetRowLeaveBackground);
            #endregion Row hover background

            #region Select/Deselect row
            this.dgvAll.CellMouseClick      += new DataGridViewCellMouseEventHandler(this.SetRowSelect);
            this.dgvSelected.CellMouseClick += new DataGridViewCellMouseEventHandler(this.SetRowSelect);
            #endregion Select/Deselect row

            #region Delete trainer button
            this.dgvSelected.CellMouseClick += delegate(object sender, DataGridViewCellMouseEventArgs e)
            {
                if (((Users)((DataGridView)sender).Rows[e.RowIndex].Tag).training_expert == "N" && e.RowIndex > -1 && e.ColumnIndex == 3)
                {
                    if (MessageAlert.Show(StringResource.CONFIRM_DELETE, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
                    {
                        int user_id = ((Users)((DataGridView)sender).Rows[e.RowIndex].Tag).id;
                        this.trainer_selected.Remove(this.trainer_selected.Find(t => t.id == user_id));
                        this.FillDgvSelected();
                    }
                }
            };
            #endregion Delete trainer button
        }
Example #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.cbUsers.SelectedItem == null)
            {
                this.cbUsers.Focus();
                SendKeys.Send("{F6}");
                return;
            }
            if (this.cbReason.SelectedItem == null)
            {
                this.cbReason.Focus();
                SendKeys.Send("{F6}");
                return;
            }
            if (this.cbMedCert.SelectedItem == null)
            {
                this.cbMedCert.Focus();
                SendKeys.Send("{F6}");
                return;
            }

            if (MessageAlert.Show("ยืนยันการบันทึกข้อมูล", "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
            {
                this.SubmitEventData();
            }
        }
Example #7
0
        public static bool CreateHolidayNote(NoteCalendar note)
        {
            string url         = PreferenceForm.API_MAIN_URL() + "notecalendar/create_holiday_note";
            string json_string = "{\"date\":\"" + note.date + "\",";

            json_string += "\"type\":" + note.type.ToString() + ",";
            json_string += "\"description\":\"" + note.description + "\",";
            json_string += "\"group_maid\":\"" + note.group_maid + "\",";
            json_string += "\"group_weekend\":\"" + note.group_weekend + "\",";
            json_string += "\"max_leave\":" + note.max_leave.ToString() + ",";
            json_string += "\"rec_by\":\"" + note.rec_by + "\"}";

            CRUDResult   get = ApiActions.POST(url, json_string);
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                return(true);
            }
            else if (sr.result == ServerResult.SERVER_CREATE_RESULT_FAILED_EXIST)
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                return(false);
            }
            else
            {
                if (MessageAlert.Show(sr.message, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                {
                    return(CreateHolidayNote(note));
                }

                return(false);
            }
        }
Example #8
0
 private void submitLogin()
 {
     using (snEntities db = DBX.DataSet())
     {
         users user = db.users.Where(u => u.username.Trim() == this.txtUser.Text.Trim() && u.userpassword.Trim() == this.txtPassword.Text.Trim()).FirstOrDefault();
         if (user != null)
         {
             if (user.level == (int)USER_LEVEL.ADMIN)
             {
                 this.loged_in_user = user;
                 this.DialogResult  = DialogResult.OK;
                 this.Close();
             }
             else
             {
                 mac_allowed mac = db.mac_allowed.Where(m => m.mac_address.Trim() == this.main_form.my_mac.Trim()).FirstOrDefault();
                 if (mac != null)
                 {
                     this.loged_in_user = user;
                     this.DialogResult  = DialogResult.OK;
                     this.Close();
                 }
                 else
                 {
                     MessageAlert.Show("เครื่องของท่านไม่ได้รับอนุญาตให้เข้าระบบ", "Error", MessageAlertButtons.OK, MessageAlertIcons.STOP);
                     return;
                 }
             }
         }
         else
         {
             MessageAlert.Show("รหัสผู้ใช้/รหัสผ่าน ไม่ถูกต้อง", "Error", MessageAlertButtons.OK, MessageAlertIcons.STOP);
         }
     }
 }
Example #9
0
        private void inquireAll()
        {
            if (this.serial_list.Count == 0)
            {
                string ids = string.Empty;
                for (int i = 0; i <= 100; i++)
                {
                    if (i == 0)
                    {
                        ids += this.serial_id_list[i].id.ToString();
                    }
                    else
                    {
                        ids += "," + this.serial_id_list[i].id.ToString();
                    }
                }

                CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "serial/get_inquiry&sort=" + this.sortMode + "&ids=" + ids);
                ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    if (sr.serial_list.Count > 0)
                    {
                        this.serial_list             = sr.serial_list;
                        this.toolStripLoadedRec.Text = this.serial_list.Count.ToString();
                        this.toolStripTotalRec.Text  = this.serial_id_list.Count.ToString();
                    }
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            List <Users> list_selected_trainer = (from r in this.dgvSelected.Rows.Cast <DataGridViewRow>()
                                                  select(Users) r.Tag).ToList <Users>();

            StringBuilder trainer_id = new StringBuilder();
            int           cnt        = 0;

            foreach (Users u in list_selected_trainer)
            {
                cnt++;
                trainer_id.Append((cnt == 1 ? u.id.ToString() : "," + u.id.ToString()));
            }

            string json_data = "{\"date\":\"" + this.date_event.Date.ToMysqlDate() + "\",";

            json_data += "\"trainer_id\":\"" + trainer_id.ToString() + "\",";
            json_data += "\"rec_by\":\"" + this.date_event.G.loged_in_user_name + "\"}";
            Console.WriteLine(" >>> " + json_data);

            CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "trainingcalendar/change", json_data);
            ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
            }
        }
Example #11
0
        private void workerSubmit_Dowork(object sender, DoWorkEventArgs e)
        {
            string json_data = "{\"id\":" + this.serial.id.ToString() + ",";

            json_data += "\"lost_sernum\":\"" + this.mskLostSernum.Text.cleanString() + "\",";
            json_data += "\"new_sernum\":\"" + this.mskNewSernum.Text.cleanString() + "\",";
            json_data += "\"version\":\"" + this.txtVersion.Text.cleanString() + "\",";
            json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\",";
            json_data += "\"is_newrwt_job\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\",";
            json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\",";
            json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";

            CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/lost_renew", json_data);
            ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

            Console.WriteLine(sr.message);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                this.DialogResult  = DialogResult.OK;
                this.submit_result = true;
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                this.submit_result = false;
            }
        }
Example #12
0
        private void toolStripDelete_Click(object sender, EventArgs e)
        {
            if (this.dgvIstab.CurrentCell == null)
            {
                return;
            }

            if (this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag is Istab)
            {
                this.dgvIstab.Tag = DGV_TAG.DELETE;

                if (MessageAlert.Show(StringResource.CONFIRM_DELETE, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
                {
                    this.FormProcessing();

                    Istab  delete_item    = (Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag;
                    bool   delete_success = false;
                    string err_msg        = "";

                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += delegate
                    {
                        CRUDResult   delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "istab/delete&id=" + ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).id.ToString());
                        ServerResult sr     = JsonConvert.DeserializeObject <ServerResult>(delete.data);

                        if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                        {
                            delete_success = true;
                        }
                        else
                        {
                            delete_success = false;
                            err_msg        = sr.message;
                        }
                    };
                    worker.RunWorkerCompleted += delegate
                    {
                        if (delete_success)
                        {
                            int delete_row_index = this.dgvIstab.Rows.Cast <DataGridViewRow>().Where(r => ((Istab)r.Tag).id == delete_item.id).First <DataGridViewRow>().Cells[1].RowIndex;
                            this.GetIstabData(null, false, delete_row_index);
                        }
                        else
                        {
                            MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                            this.dgvIstab.Tag = DGV_TAG.NORMAL;
                            this.FormRead();
                        }
                    };
                    worker.RunWorkerAsync();
                }
                else
                {
                    this.FillInDatagrid((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag);
                }
            }
        }
Example #13
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool post_success = false;

            this.formSaving();

            BackgroundWorker workerSave = new BackgroundWorker();

            workerSave.DoWork += delegate
            {
                string json_data = "{\"sernum\":\"" + this.mskSernum.Text + "\",";
                json_data += "\"qty\":" + this.numQty.Value.ToString() + ",";
                json_data += "\"version\":\"" + this.txtVersion.Text + "\",";
                json_data += "\"dealer\":\"" + this.txtDealer.Text + "\",";
                json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"is_newrwtjob\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";


                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/generate_sn", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    this.parent_window.serial          = sr.serial[0];
                    this.parent_window.busityp         = (sr.busityp.Count > 0 ? sr.busityp[0] : new Istab());
                    this.parent_window.area            = (sr.area.Count > 0 ? sr.area[0] : new Istab());
                    this.parent_window.howknown        = (sr.howknown.Count > 0 ? sr.howknown[0] : new Istab());
                    this.parent_window.verext          = (sr.verext.Count > 0 ? sr.verext[0] : new Istab());
                    this.parent_window.dealer          = (sr.dealer.Count > 0 ? sr.dealer[0] : new Dealer());
                    this.parent_window.problem         = new List <Problem>();
                    this.parent_window.problem_im_only = new List <Problem>();
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    post_success = false;
                }
            };

            workerSave.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    this.formEdit();
                }
            };

            workerSave.RunWorkerAsync();
        }
Example #14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            TimeSpan ts = TimeSpan.Parse(this.tmTo.Value.Hour.ToString() + ":" + this.tmTo.Value.Minute.ToString() + ":00") - TimeSpan.Parse(this.tmFrom.Value.Hour.ToString() + ":" + this.tmFrom.Value.Minute.ToString() + ":00");

            if (this.support_note == null) // add mode
            {
                string json_data = "{\"date\":\"" + this.date.ToMysqlDate() + "\",";
                json_data += "\"sernum\":\"\",";
                json_data += "\"start_time\":\"" + this.tmFrom.Text + ":00\",";
                json_data += "\"end_time\":\"" + this.tmTo.Text + ":00\",";
                json_data += "\"duration\":\"" + ts.ToString().Substring(0, 8) + "\",";
                json_data += "\"reason\":\"" + SupportNote.BREAK_REASON.TRAINING_TRAINER.FormatBreakReson() + "\",";
                json_data += "\"remark\":\"\",";
                json_data += "\"users_name\":\"" + this.user.username + "\",";
                json_data += "\"is_break\":\"Y\",";
                json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}";

                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create_break", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            }
            else // update mode
            {
                string json_data = "{\"id\":" + this.support_note.id.ToString() + ",";
                json_data += "\"date\":\"" + this.date.ToMysqlDate() + "\",";
                json_data += "\"sernum\":\"\",";
                json_data += "\"start_time\":\"" + this.tmFrom.Text + ":00\",";
                json_data += "\"end_time\":\"" + this.tmTo.Text + ":00\",";
                json_data += "\"duration\":\"" + ts.ToString().Substring(0, 8) + "\",";
                json_data += "\"reason\":\"" + SupportNote.BREAK_REASON.TRAINING_TRAINER.FormatBreakReson() + "\",";
                json_data += "\"remark\":\"\",";
                json_data += "\"users_name\":\"" + this.user.username + "\",";
                json_data += "\"is_break\":\"Y\",";
                json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}";

                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/update_break", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            }
        }
Example #15
0
        private void IstabWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.MdiFormClosing && this.form_mode != FORM_MODE.READ)
            {
                this.Activate();
                if (MessageAlert.Show(StringResource.CONFIRM_CLOSE_WINDOW, "SN_Net", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.WARNING) == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (e.CloseReason == CloseReason.UserClosing && this.form_mode != FORM_MODE.READ)
            {
                this.Activate();
                if (MessageAlert.Show(StringResource.CONFIRM_CLOSE_WINDOW, "SN_Net", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.WARNING) == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            switch (this.tabtyp)
            {
            case Istab.TABTYP.AREA:
                this.main_form.area_wind = null;
                break;

            case Istab.TABTYP.VEREXT:
                this.main_form.verext_wind = null;
                break;

            case Istab.TABTYP.HOWKNOWN:
                this.main_form.howknown_wind = null;
                break;

            case Istab.TABTYP.BUSITYP:
                this.main_form.busityp_wind = null;
                break;

            case Istab.TABTYP.PROBLEM_CODE:
                this.main_form.probcode_wind = null;
                break;

            case Istab.TABTYP.ABSENT_CAUSE:
                this.main_form.leavecause_wind = null;
                break;

            case Istab.TABTYP.SERVICE_CASE:
                this.main_form.servicecase_wind = null;
                break;

            default:
                break;
            }
        }
Example #16
0
        private void SaveCloudSrv()
        {
            bool   post_success = false;
            string err_msg      = "";

            this.cloudDateFrom.Read_Only = true;
            this.cloudDateTo.Read_Only   = true;
            this.cloudEmail.Read_Only    = true;

            string json_data = "{\"sernum\":\"" + this.parent_window.serial.sernum.cleanString() + "\",";

            json_data += "\"start_date\":\"" + this.date_from.ToMysqlDate() + "\",";
            json_data += "\"end_date\":\"" + this.date_to.ToMysqlDate() + "\",";
            json_data += "\"email\":\"" + this.email.cleanString() + "\",";
            json_data += "\"rec_by\":\"" + this.parent_window.main_form.G.loged_in_user_name + "\"}";

            Console.WriteLine(" ... > " + json_data);

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "cloudsrv/create_or_update", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                }
                else
                {
                    post_success = false;
                    err_msg      = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                    {
                        this.SaveCloudSrv();
                    }
                    this.cloudDateFrom.Read_Only = false;
                    this.cloudDateTo.Read_Only   = false;
                    this.cloudEmail.Read_Only    = false;
                }
            };
            worker.RunWorkerAsync();
        }
Example #17
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.txtTypcod.Text.Length > 0)
            {
                CRUDResult post;
                if (this.mode == FORM_MODE.ADD) // Add
                {
                    Console.WriteLine("current tabtyp = " + Istab.getTabtypString(this.tabtyp));
                    string json_data = "{\"tabtyp\":\"" + Istab.getTabtypString(this.tabtyp) + "\",";
                    json_data += "\"typcod\":\"" + this.txtTypcod.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\",";
                    json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\",";
                    json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}";

                    Console.WriteLine(json_data);
                    post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/create", json_data);
                }
                else // Edit
                {
                    string json_data = "{\"id\":" + this.istab.id.ToString() + ",";
                    json_data += "\"tabtyp\":\"" + this.istab.tabtyp + "\",";
                    json_data += "\"typcod\":\"" + this.istab.typcod + "\",";
                    json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\",";
                    json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\",";
                    json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}";

                    Console.WriteLine(json_data);
                    post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data);
                }

                ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data);
                Console.WriteLine(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    if (sr.istab != null)
                    {
                        this.istab = sr.istab[0];
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            }
            else
            {
                MessageAlert.Show(StringResource.PLEASE_FILL_CODE, "Warning", MessageAlertButtons.OK, MessageAlertIcons.WARNING);
                this.txtTypcod.Focus();
            }
        }
Example #18
0
 private void btnSubmitMacAddress_Click(object sender, EventArgs e)
 {
     if (this.txtMacAddress.Text.Length > 0)
     {
         this.addMacAddress(this.txtMacAddress.Text);
     }
     else
     {
         MessageAlert.Show("กรุณาป้อน MAC Address");
     }
 }
Example #19
0
 private void btnStopComplain_Click(object sender, EventArgs e)
 {
     if (this.prepared_comment.type == (int)COMMENT_TYPE.COMPLAIN)
     {
         if (MessageAlert.Show(StringResource.CONFIRM_CANCEL_ADD_EDIT, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
         {
             this.ClearInlineForm(this.dgvComplain);
             this.dgvComplain.Focus();
             this.FormRead();
         }
     }
 }
Example #20
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.formSaving();
            bool post_success = false;

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                string json_data = "{\"id\":" + this.parent_window.serial.id.ToString() + ",";
                json_data += "\"sernum_old\":\"" + this.mskOldSernum.Text + "\",";
                json_data += "\"sernum_2\":\"" + this.msk2Sernum.Text + "\",";
                json_data += "\"version\":\"" + this.txtVersion.Text + "\",";
                json_data += "\"dealer_dealer\":\"" + this.txtDealer.Text + "\",";
                json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";

                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/sell_program_2nd", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    this.parent_window.serial          = sr.serial[0];
                    this.parent_window.busityp         = (sr.busityp.Count > 0 ? sr.busityp[0] : new Istab());
                    this.parent_window.area            = (sr.area.Count > 0 ? sr.area[0] : new Istab());
                    this.parent_window.howknown        = (sr.howknown.Count > 0 ? sr.howknown[0] : new Istab());
                    this.parent_window.verext          = (sr.verext.Count > 0 ? sr.verext[0] : new Istab());
                    this.parent_window.dealer          = (sr.dealer.Count > 0 ? sr.dealer[0] : new Dealer());
                    this.parent_window.problem         = (sr.problem.Count > 0 ? sr.problem : new List <Problem>());
                    this.parent_window.problem_im_only = (sr.problem.Count > 0 ? this.parent_window.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>());
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    post_success = false;
                }
            };

            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    this.formEdit();
                }
            };

            worker.RunWorkerAsync();
        }
Example #21
0
        private void toolStripRangeLeave_Click(object sender, EventArgs e)
        {
            LeaveRange wind = new LeaveRange(this.main_form);

            if (wind.ShowDialog() == DialogResult.OK)
            {
                MessageAlert.Show("บันทึกข้อมูลเรียบร้อย", "", MessageAlertButtons.OK, MessageAlertIcons.INFORMATION);

                if ((wind.dtDateStart.Value.Year == this.curr_year && wind.dtDateStart.Value.Month == this.curr_month) || (wind.dtDateEnd.Value.Year == this.curr_year && wind.dtDateEnd.Value.Month == this.curr_month))
                {
                    this.LoadCalendar(this.curr_month, this.curr_year);
                }
            }
        }
Example #22
0
        private void UpdateData()
        {
            this.FormProcessing();
            Istab data = this.GetDataInForm();

            bool   post_success = false;
            string err_msg      = "";

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                string json_data = "{\"id\":" + data.id.ToString() + ",";
                json_data += "\"tabtyp\":\"" + Istab.getTabtypString(this.tabtyp) + "\",";
                json_data += "\"typcod\":\"" + data.typcod.cleanString() + "\",";
                json_data += "\"abbreviate_th\":\"" + data.abbreviate_th.cleanString() + "\",";
                json_data += "\"abbreviate_en\":\"" + data.abbreviate_en.cleanString() + "\",";
                json_data += "\"typdes_th\":\"" + data.typdes_th.cleanString() + "\",";
                json_data += "\"typdes_en\":\"" + data.typdes_en.cleanString() + "\"}";

                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                }
                else
                {
                    post_success = false;
                    err_msg      = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.GetIstabData(data);
                }
                else
                {
                    MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    this.FormEdit();
                    if (this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true).Length > 0)
                    {
                        ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true)[0]).textBox1.Focus();
                    }
                }
            };
            worker.RunWorkerAsync();
        }
 private void btnClear_Click(object sender, EventArgs e)
 {
     if (MessageAlert.Show("Clear expression and all query result data?", "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
     {
         this.txtExpression.Text       = "";
         this.toolStripSelectedID.Text = "# ";
         this.toolStripLoadedRow.Text  = "0";
         //this.dgvDealer.DataSource = null;
         this.dealer_list.Clear();
         this.FillDataGrid();
         this.btnOK.Enabled = false;
         this.cbDataField.Focus();
     }
 }
Example #24
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool post_success = false;

            this.formSaving();
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                string json_data = "{\"id\":" + this.parent_window.serial.id.ToString() + ",";
                json_data += "\"sernum_from\":\"" + this.mskSernumFrom.Text + "\",";
                json_data += "\"sernum_to\":\"" + this.mskSernumTo.Text + "\",";
                json_data += "\"version\":\"" + this.txtVersion.Text + "\",";
                json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"is_newrwt_job\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\",";
                json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";

                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/upgrade_program", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    this.parent_window.serial          = sr.serial[0];
                    this.parent_window.problem         = sr.problem;
                    this.parent_window.problem_im_only = (sr.problem.Count > 0 ? sr.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>());
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    post_success = false;
                }
            };

            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    this.formEdit();
                }
            };

            worker.RunWorkerAsync();
        }
        private void SubmitPassword()
        {
            bool   post_success = false;
            string err_msg      = "";

            string json_data = "{\"sernum\":\"" + this.sn_wind.serial.sernum + "\",";

            json_data += "\"pass_word\":\"" + this.txtPassword.Texts.cleanString() + "\",";
            json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}";

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                CRUDResult   post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serialpassword/create", json_data);
                ServerResult sr   = JsonConvert.DeserializeObject <ServerResult>(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success     = true;
                    this.inserted_id = (sr.serial_password.Count > 0 ? sr.serial_password[0].id : -1);
                }
                else
                {
                    post_success = false;
                    err_msg      = sr.message;
                }
            };

            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                    {
                        this.SubmitPassword(); // if error occured and retry again
                        return;
                    }

                    this.btnCancel.PerformClick(); // if error occured and do not retry
                }
            };

            worker.RunWorkerAsync();
        }
Example #26
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (this.prepared_comment != null)
            {
                if (MessageAlert.Show(StringResource.CONFIRM_CLOSE_WINDOW, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            this.axWindowsMediaPlayer1.Ctlcontrols.stop();
            this.axWindowsMediaPlayer1.Dispose();
            base.OnClosing(e);
        }
Example #27
0
        public static DialogResult Show(string message, string caption)
        {
            MessageAlert m = new MessageAlert();

            m.lblMessage.Text = message;
            m.Text            = caption;
            // Set lblMessage position,size , hide pictureBoxIcon
            m.pictureBoxIcon.SetBounds(0, 0, 0, 0);
            m.lblMessage.SetBounds(m.lblMessage.Location.X - 55, m.lblMessage.Location.Y, m.lblMessage.ClientSize.Width + 55, m.lblMessage.ClientSize.Height);
            // Set OK button to show
            m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
            m.btnOK.Visible = true;

            return(m.ShowDialog());
        }
Example #28
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            NoteCalendar note_calendar = (NoteCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Cells["colNoteCalendar"].Value;

            note_calendar.rec_by = this.main_form.G.loged_in_user_name;
            if (MessageAlert.Show("ลบวันที่ " + note_calendar._Date.ToString("d MMM yy", CultureInfo.GetCultureInfo("th-TH")) + " ออกจากว้นหยุดประจำปี, ทำต่อหรือไม่?", "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
            {
                if (DeleteHolidayNote(note_calendar) == true)
                {
                    this.bs.ResetBindings(true);
                    this.bs.DataSource = GetNoteCalendarList(this.current_year).ToHolidayViewModel();
                    this.calendar.RefreshAtDate(note_calendar._Date);
                }
            }
        }
        private List <Users> GetTrainerAll()
        {
            CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_trainer");
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                return(sr.users);
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                return(null);
            }
        }
        private List <Users> GetTrainerSelected()
        {
            CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "trainingcalendar/get_trainer&date_from=" + this.date_event.Date.ToMysqlDate() + "&date_to=" + this.date_event.Date.ToMysqlDate());
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                return(sr.users);
            }
            else
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                return(null);
            }
        }
Example #31
0
        public static DialogResult Show(string message, string caption, MessageAlertButtons button, MessageAlertIcons icon)
        {
            MessageAlert m = new MessageAlert();
            m.lblMessage.Text = message;
            m.Text = caption;
            m.setIconImage(icon);

            switch (button)
            {
                case MessageAlertButtons.OK:
                    m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
                    m.btnOK.Visible = true;
                    break;
                case MessageAlertButtons.OK_CANCEL:
                    m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height);
                    m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
                    m.btnOK.Visible = true;
                    m.btnCancel.Visible = true;
                    m.btnCancel.Focus();
                    break;
                case MessageAlertButtons.YES:
                    m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height);
                    m.btnYes.Visible = true;
                    break;
                case MessageAlertButtons.YES_NO:
                    m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height);
                    m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height);
                    m.btnYes.Visible = true;
                    m.btnNo.Visible = true;
                    break;
                case MessageAlertButtons.RETRY_CANCEL:
                    m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height);
                    m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height);
                    m.btnRetry.Visible = true;
                    m.btnCancel.Visible = true;
                    m.btnCancel.Focus();
                    break;
                default:
                    break;
            }
            return m.ShowDialog();
        }
Example #32
0
        public static DialogResult Show(string message, string caption, MessageAlertButtons button)
        {
            MessageAlert m = new MessageAlert();
            m.lblMessage.Text = message;
            m.Text = caption;
            // Set lblMessage position,size , hide pictureBoxIcon
            m.pictureBoxIcon.SetBounds(0, 0, 0, 0);
            m.lblMessage.SetBounds(m.lblMessage.Location.X - 55, m.lblMessage.Location.Y, m.lblMessage.ClientSize.Width + 55, m.lblMessage.ClientSize.Height);

            switch (button)
            {
                case MessageAlertButtons.OK:
                    m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
                    m.btnOK.Visible = true;
                    break;
                case MessageAlertButtons.OK_CANCEL:
                    m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height);
                    m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
                    m.btnOK.Visible = true;
                    m.btnCancel.Visible = true;
                    break;
                case MessageAlertButtons.YES:
                    m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height);
                    m.btnYes.Visible = true;
                    break;
                case MessageAlertButtons.YES_NO:
                    m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height);
                    m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height);
                    m.btnYes.Visible = true;
                    m.btnNo.Visible = true;
                    break;
                case MessageAlertButtons.RETRY_CANCEL:
                    m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height);
                    m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height);
                    m.btnRetry.Visible = true;
                    m.btnCancel.Visible = true;
                    break;
                default:
                    break;
            }
            return m.ShowDialog();
        }
Example #33
0
        public static DialogResult Show(string message)
        {
            MessageAlert m = new MessageAlert();
            m.lblMessage.Text = message;
            // Set form caption to blank
            m.Text = "";
            // Set lblMessage position,size , hide pictureBoxIcon
            m.pictureBoxIcon.SetBounds(0, 0, 0, 0);
            m.lblMessage.SetBounds(m.lblMessage.Location.X - 55, m.lblMessage.Location.Y, m.lblMessage.ClientSize.Width + 55, m.lblMessage.ClientSize.Height);
            // Set OK button to show
            m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height);
            m.btnOK.Visible = true;

            return m.ShowDialog();
        }