private void UpdateSupplierDetails(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository       = dbRepository;
            var selectedSupplier = repository.Suppliers.GetById(GetSupplierId());

            {
                selectedSupplier.Email            = txtEmail.Text;
                selectedSupplier.ContactNo        = txtContactNo.Text;
                selectedSupplier.SupplierName     = txtSupplierName.Text;
                selectedSupplier.Address          = txtAddress.Text;
                selectedSupplier.DateTimeModified = DateTime.Now;
            };
            repository.Commit();

            MessageAlert.Show("Successfully Changed");
            ResetToDefault();
        }
        private void SaveNewAttendant(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository   = dbRepository;
            var newAttendant = new Employee()
            {
                FirstName    = txtFirstName.Text,
                EmployeeCode = txtAttendantCode.Text.Trim(),
                ContactNo    = txtContactNo.Text,
                Address      = txtAttendantAddress.Text,
                LastName     = txtLastName.Text.Trim(),
                FullName     = $"{txtFirstName.Text} {txtLastName.Text}",
                IsActive     = true,
                PositionId   = 1

                               //CreatedBy = AccountSession.GetAccount.Id
            };

            repository.PumpAttendants.Add(newAttendant);
            repository.Commit();

            ResetToDefault();
            MessageAlert.Show("New Attendant has successfully added.", "New Attendant", AlertType.Info);
        }
        private void UpdateProductDetails(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }
            if (FlatMessageBox.Show("Do you want to update the changes?", "Update Product", DialogButtons.YesNo,
                                    DialogType.Question) == DialogButton.Yes)
            {
                var repository      = dbRepository;
                var selectedProduct = repository.Products.GetById(GetProductId());
                {
                    selectedProduct.ProductCode      = txtProductCode.Text.Trim();
                    selectedProduct.ProductName      = txtProductCode.Text.Trim();
                    selectedProduct.SalesRate        = decimal.Parse(txtSalesRate.Text);
                    selectedProduct.PurchaseRate     = decimal.Parse(txtPurchaseRate.Text);
                    selectedProduct.Unit             = txtUnit.Text.Trim();
                    selectedProduct.Description      = txtDescription.Text.Trim();
                    selectedProduct.Quantity         = int.Parse(txtQuantity.Text);
                    selectedProduct.DateTimeModified = DateTime.Now;
                    //selectedProduct.ModifiedBy = AccountSession.GetAccount.Id;
                };
                repository.Commit();
            }

            MessageAlert.Show("Successfully Changed");
            ResetToDefault();
        }
        private void SaveSupplierDetails(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository = dbRepository;
            var supplier   = new Models.Supplier()
            {
                SupplierName    = txtSupplierName.Text,
                ContactNo       = txtContactNo.Text,
                Email           = txtEmail.Text,
                Address         = txtAddress.Text.Trim(),
                IsActive        = true,
                DateTimeCreated = DateTime.Now


                                  //CreatedBy = AccountSession.GetAccount.Id
            };

            repository.Suppliers.Add(supplier);
            repository.Commit();

            ResetToDefault();
            MessageAlert.Show("New supplier has successfully added.", "Supplier", AlertType.Info);
        }
Beispiel #5
0
        async void CreateUser()
        {
            Android.App.AlertDialog dialog = new SpotsDialog(this);
            dialog.Show();
            user = new User {
                Email       = auth.CurrentUser.Email,
                Id          = auth.CurrentUser.Uid.ToString(),
                FirstName   = firstName.Text,
                LastName    = lastName.Text,
                Country     = country.Text,
                City        = city.Text,
                DateOfBirth = dateOfBirth
            };
            var response = await AccountsApi.RegisterNew(user);

            if (response.Succeed)
            {
                LocalProvider.SetCurrentUser(user);
                StartActivity(new Intent(this, typeof(UserProfile)));
                Finish();
            }
            else
            {
                var newFragment = new MessageAlert(response.Errors);
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
            }
            dialog.Dismiss();
        }
Beispiel #6
0
        async void UpdateUser()
        {
            Android.App.AlertDialog dialog = new SpotsDialog(this);
            dialog.Show();
            try {
                user.FirstName = firstName.Text;
                user.LastName  = lastName.Text;
                user.Country   = country.Text;
                user.City      = city.Text;
                if (dateOfBirth != null)
                {
                    user.DateOfBirth = dateOfBirth;
                }

                var response = await AccountsApi.UpdateCurentUser(user);

                if (response.Succeed)
                {
                    LocalProvider.SetCurrentUser(user);
                    StartActivity(new Intent(this, typeof(UserProfile)));
                    Finish();
                }
                else
                {
                    var newFragment = new MessageAlert(response.Errors);
                    newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                }
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine($"{this.GetType().Name}: Exception: {ex.Message}");
            }
            dialog.Dismiss();
        }
Beispiel #7
0
        public void OnRegisterButtonClick(View view)
        {
            if (String.IsNullOrEmpty(input_email?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.emptyEmail));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (!IsValidEmail(input_email?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.ERROR_INVALID_EMAIL));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (String.IsNullOrEmpty(input_password?.Text) || String.IsNullOrEmpty(input_password_confirm?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.emptyPassword));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (input_password?.Length() < 6)
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.weakPassword));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (input_password?.Text != input_password_confirm?.Text)
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.passwordMistmatch));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }

            SignUpUser(input_email?.Text, input_password?.Text);
        }
Beispiel #8
0
        private void UpdateAccountDetails(DbRepository userRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository = userRepository;
            var accountId  = GetAccountId(dgvAccount);
            var account    = repository.Users.GetById(accountId);

            if (account != null)
            {
                account.Name     = txtName.Text;
                account.Password = txtPassword.Text;
                account.RoleId   = (int)txtUserRole.SelectedValue;
                account.Username = txtUsername.Text;

                repository.Commit();
                MessageAlert.Show("Successfully Changed", "Update");
                ResetToDefault();
            }
        }
Beispiel #9
0
        private void UpdateCustomerDetails(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository = dbRepository;
            var customer   = repository.Customers.GetById(GetCustomerId());

            {
                customer.VehicleNo    = txtVehicleNo.Text;
                customer.ContactNo    = txtContactNo.Text;
                customer.CustomerName = txtSupplierName.Text;
                //customer.Address = txtCustomerCode.Text;
                customer.CustomerCode     = txtCustomerCode.Text;
                customer.DateTimeModified = DateTime.Now;
                customer.ModifiedBy       = 1;
            };
            repository.Commit();

            MessageAlert.Show("Successfully Changed");
            ResetToDefault();
        }
Beispiel #10
0
        private void SaveNewAccount(DbRepository userRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }


            var repository = userRepository;

            var newAccount = new User()
            {
                Name            = txtName.Text,
                Password        = txtPassword.Text,
                RoleId          = (int)txtUserRole.SelectedValue,
                Username        = txtUsername.Text,
                IsActive        = true,
                DateTimeCreated = DateTime.Now
            };

            repository.Users.Add(newAccount);
            repository.Commit();
            MessageAlert.Show("Successfully Saved");
            ResetToDefault();
        }
        private void UpdateAttendantDetails(DbRepository dbRepository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var repository        = dbRepository;
            var selectedAttendant = repository.PumpAttendants.GetById(GetPumpAttendantId());

            {
                selectedAttendant.FirstName    = txtFirstName.Text;
                selectedAttendant.Address      = txtAttendantAddress.Text;
                selectedAttendant.ContactNo    = txtContactNo.Text;
                selectedAttendant.EmployeeCode = txtAttendantCode.Text;
                selectedAttendant.LastName     = txtLastName.Text;
                selectedAttendant.FullName     = $"{txtFirstName.Text} {txtLastName.Text}";
            };
            repository.Commit();

            MessageAlert.Show("Successfully Changed");
            ResetToDefault();
        }
Beispiel #12
0
        public CustomLabel()
        {
            InitializeComponent();

            this.lblMaid.Click += delegate
            {
                List <Users> users = this.GetUserInGroup(this.note_calendar.group_maid);
                string       user  = "******";

                int cnt = 0;
                foreach (Users u in users)
                {
                    user += u.name + (++cnt < users.Count ? ", " : "");
                }

                MessageAlert.Show(user);
            };

            this.lblWeekend.Click += delegate
            {
                List <Users> users = this.GetUserInGroup(this.note_calendar.group_weekend);
                string       user  = "******";

                int cnt = 0;
                foreach (Users u in users)
                {
                    user += u.name + (++cnt < users.Count ? ", " : "");
                }

                MessageAlert.Show(user);
            };
        }
Beispiel #13
0
        public async Task Reload(Context context = null)
        {
            if (context == null)
            {
                context = Context;
            }
            ProgressAlert alert = new ProgressAlert("Refreshing scrobbles", "Please wait...", context);

            alert.Show();
            if (SourceUser != null)
            {
                ReythScrobbles.Clear();
                var res = await client.User.GetRecentScrobbles(SourceUser, null, 1, 100);

                if (res.Success)
                {
                    ReythScrobbles.AddRange(res);
                }
            }
            if (client.Auth.UserSession != null)
            {
                var userRes = await client.User.GetRecentScrobbles(client.Auth.UserSession.Username, null, 1, 100);

                GinaScrobbles.Clear();
                if (userRes.Success)
                {
                    GinaScrobbles.AddRange(userRes);
                }
            }

            if (ReythAdapter == null)
            {
                ReythAdapter = new ScrobbleListAdapter(ReythScrobbles.ToArray(), (e, a) =>
                {
                    var vh = a.View.Tag as ScrobbleListAdapterViewHolder;
                    vh.ChangeChecked();
                });
            }
            else
            {
                ReythAdapter.SetItems(ReythScrobbles);
            }
            if (GinaAdapter == null)
            {
                GinaAdapter = new ScrobbleListAdapter(GinaScrobbles.ToArray());
            }
            else
            {
                GinaAdapter.SetItems(GinaScrobbles);
            }
            alert.Hide();
            if (string.IsNullOrEmpty(SourceUser))
            {
                var msg = new MessageAlert("Source User Not Set!", "Use the 'Set Source' option from the menu to pick the user whose scrobbles you want to sync.", context);
                msg.Show();
            }
        }
Beispiel #14
0
 private bool ValidateSelectedRecord()
 {
     if (dgvCustomers.RowCount == 0)
     {
         MessageAlert.Show(MessageHelper.NoSelectedRecord(), "Error", AlertType.BadInfo);
         return(false);
     }
     return(true);
 }
 private bool ValidateSelectedRecord()
 {
     if (!IsNew && dgvProduct.RowCount == 0)
     {
         MessageAlert.Show(MessageHelper.NoSelectedRecord(), "Error", AlertType.BadInfo);
         return(false);
     }
     return(true);
 }
Beispiel #16
0
        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ChangePasswordForm wind = new ChangePasswordForm();

            wind.G = this.G;
            if (wind.ShowDialog() == DialogResult.OK)
            {
                MessageAlert.Show("เปลี่ยนรหัสผ่านเรียบร้อย\nกรุณาออกจากระบบ และ ล็อกอินเข้าระบบใหม่อีกครั้ง", "Information", MessageAlertButtons.OK, MessageAlertIcons.INFORMATION);
            }
        }
Beispiel #17
0
 private void ShowAlert()
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action(ShowAlert), new object[] { });
     }
     else
     {
         MessageAlert alert = new MessageAlert("当前已是最新版本,无需更新!");
         alert.StartPosition = FormStartPosition.CenterScreen;
         alert.Show();
     }
 }
Beispiel #18
0
 public void AlertTip(string text)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <string>(AlertTip), new object[] { text });
     }
     else
     {
         MessageAlert alert = new MessageAlert(text, "提示");
         alert.StartPosition = FormStartPosition.CenterScreen;
         alert.Show(this);
     }
 }
Beispiel #19
0
        private void DeleteAccount()
        {
            if (dgvDeletedUsers.Rows.Count < 1)
            {
                return;
            }

            using (var repository = new DbRepository(new DatabaseContext()))
            {
                var accountId = GetAccountId(dgvDeletedUsers);
                var account   = repository.Users.GetById(accountId);
                repository.Users.Remove(account);
                repository.Commit();
                MessageAlert.Show("Successfully Deleted");
                ResetToDefault();
            }
        }
Beispiel #20
0
        private void btnMaid_Click(object sender, EventArgs e)
        {
            this.Focus();
            string str_group = ((ToolStripButton)sender).Text.Trim();

            if (str_group.Length == 0)
            {
                return;
            }

            string user_in_group = "สมาชิกในกลุ่ม " + str_group + " : ";

            foreach (var user in this.users_list.Where(u => u.usergroup != null).Where(u => u.usergroup.Trim() == str_group).OrderBy(u => u.username))
            {
                user_in_group += user.id == this.users_list.Where(u => u.usergroup != null).Where(u => u.usergroup.Trim() == str_group).OrderBy(u => u.username).First().id ? "" : ", ";
                user_in_group += user.name;
            }

            MessageAlert.Show(user_in_group, "", MessageAlertButtons.OK, MessageAlertIcons.NONE);
        }
Beispiel #21
0
        private void DeActivateAccount()
        {
            if (dgvAccount.Rows.Count < 1)
            {
                return;
            }
            using (var repository = new DbRepository(new DatabaseContext()))
            {
                var accountId = GetAccountId(dgvAccount);
                var account   = repository.Users.GetById(accountId);
                if (account != null)
                {
                    account.IsActive = false;

                    repository.Commit();
                    MessageAlert.Show("Successfully Deactivated selected account", "DeActivate", AlertType.Delete);
                    ResetToDefault();
                }
            }
        }
Beispiel #22
0
        private async void LoginUser(string email, string password)
        {
            Android.App.AlertDialog dialog = new SpotsDialog(this);
            dialog.Show();

            try {
                var user = await FirebaseAuth.Instance.SignInWithEmailAndPasswordAsync(email, password);

                if (user != null)
                {
                    var response = await AccountsApi.GetCurentUser();

                    if (response.Succeed)
                    {
                        LocalProvider.SetCurrentUser(response.ResponseObject);
                        StartActivity(new Android.Content.Intent(this, typeof(UserProfile)));
                        Finish();
                    }
                    else
                    {
                        var newFragment = new MessageAlert(response.Errors);
                        newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                    }
                }
                else
                {
                    var newFragment = new MessageAlert(Resources.GetText(Resource.String.noUserAccess));
                    newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                }
            } catch (FirebaseAuthException ex) {
                var eee   = ex.ErrorCode;
                int errID = Resources.GetIdentifier(eee, "string", PackageName);


                var newFragment = new MessageAlert(Resources.GetText(errID));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
            }

            dialog.Dismiss();
        }
Beispiel #23
0
        private async void SignUpUser(string email, string password)
        {
            Android.App.AlertDialog dialog = new SpotsDialog(this);
            dialog.Show();
            try {
                var user = await FirebaseAuth.Instance.CreateUserWithEmailAndPasswordAsync(email, password);

                if (user != null)
                {
                    StartActivity(new Intent(this, typeof(UserInfo)));
                    Finish();
                }
            } catch (FirebaseAuthException ex) {
                var eee   = ex.ErrorCode;
                int errID = Resources.GetIdentifier(eee, "string", PackageName);


                var newFragment = new MessageAlert(Resources.GetText(errID));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
            }
            dialog.Dismiss();
        }
Beispiel #24
0
        private void ActivateAccount()
        {
            if (dgvDeletedUsers.Rows.Count < 1)
            {
                return;
            }

            using (var repository = new DbRepository(new DatabaseContext()))
            {
                var  accountId = GetAccountId(dgvDeletedUsers);
                User account   = repository.Users.GetById(accountId);
                if (account != null)
                {
                    account.IsActive = true;

                    repository.Commit();
                    MessageAlert.Show("Account successfully activated", "Activate");

                    ResetToDefault();
                }
            }
        }
Beispiel #25
0
        public void OnLoginButtonClick(View view)
        {
            if (String.IsNullOrEmpty(email?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.emptyEmail));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (!IsValidEmail(email?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.ERROR_INVALID_EMAIL));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }
            if (String.IsNullOrEmpty(password?.Text))
            {
                var newFragment = new MessageAlert(Resources.GetText(Resource.String.emptyPassword));
                newFragment.Show(FragmentManager.BeginTransaction(), "dialog");
                return;
            }

            LoginUser(email?.Text, password?.Text);
        }
        private void DeleteProduct()
        {
            if (!ValidateSelectedRecord())
            {
                return;
            }

            if (FlatMessageBox.Show("Selected product will be deleted. Do you want to continue?", "Delete Product", DialogButtons.YesNo, DialogType.Warning) ==
                DialogButton.Yes)
            {
                using (var repository = new DbRepository(new DatabaseContext()))
                {
                    var selectedProduct = repository.Products.GetById(GetProductId());
                    if (selectedProduct != null)
                    {
                        repository.Products.Remove(selectedProduct);
                        repository.Commit();
                        MessageAlert.Show("Product successfully removed from the list", "Deleted", AlertType.Delete);
                        ShowProducts();
                    }
                }
            }
        }
        private bool ValidateDuplicateRecord()
        {
            ClearErrors();

            var isValidated = true;

            using (var repository = new DbRepository(new DatabaseContext()))
            {
                var fullName = $"{txtSupplierName.Text}";

                if (IsNew)
                {
                    if (repository.Suppliers.IsExist(fullName))
                    {
                        MessageAlert.Show(MessageHelper.DuplicateRecord(fullName), "Error", AlertType.Warning);

                        //isValidated = SetErrorMessage(txtSupplierName, MessageHelper.DuplicateRecord(txtSupplierName.Text));

                        return(isValidated);
                    }
                }
                else
                {
                    var supplierId = GetSupplierId();
                    if (repository.Suppliers.IsExist(fullName, supplierId))
                    {
                        MessageAlert.Show(MessageHelper.DuplicateRecord(fullName), "Error", AlertType.Warning);

                        //isValidated = SetErrorMessage(txtSupplierName, MessageHelper.DuplicateRecord(txtSupplierName.Text));

                        return(isValidated);
                    }
                }
            }

            return(isValidated);
        }
        private void SaveNewProduct(DbRepository repository)
        {
            if (!ValidateRequiredFields())
            {
                return;
            }
            if (!ValidateDuplicateRecord())
            {
                return;
            }

            var productRepository = repository;

            if (FlatMessageBox.Show("Do you want to save new product?", "Update Product", DialogButtons.YesNo,
                                    DialogType.Question) == DialogButton.Yes)
            {
                var newProduct = new Products()
                {
                    ProductCode     = txtProductCode.Text.Trim(),
                    ProductName     = txtProductCode.Text.Trim(),
                    SalesRate       = decimal.Parse(txtSalesRate.Text),
                    PurchaseRate    = decimal.Parse(txtPurchaseRate.Text),
                    Unit            = txtUnit.Text.Trim(),
                    Description     = txtDescription.Text.Trim(),
                    Quantity        = int.Parse(txtQuantity.Text),
                    DateTimeCreated = DateTime.Now,
                    IsActive        = true
                };
                productRepository.Products.Add(newProduct);
                productRepository.Commit();
            }



            ResetToDefault();
            MessageAlert.Show("New product has successfully added.", "New Product", AlertType.Info);
        }
        private bool ValidateDuplicateRecord()
        {
            ClearErrors();

            var isValidated = true;

            using (var repository = new DbRepository(new DatabaseContext()))
            {
                var fullName = $"{txtFirstName.Text} {txtLastName.Text}";

                if (IsNew)
                {
                    if (repository.PumpAttendants.AttendantNameAlreadyExist(fullName))
                    {
                        MessageAlert.Show(MessageHelper.DuplicateRecord(fullName), "Error", AlertType.Warning);

                        isValidated = SetErrorMessage(txtFirstName, MessageHelper.DuplicateRecord(txtFirstName.Text));
                        isValidated = SetErrorMessage(txtLastName, MessageHelper.DuplicateRecord(txtLastName.Text));
                        return(isValidated);
                    }
                }
                else
                {
                    var pumpAttendantId = GetPumpAttendantId();
                    if (repository.PumpAttendants.AttendantNameAlreadyExist(fullName, pumpAttendantId))
                    {
                        isValidated = SetErrorMessage(txtFirstName, MessageHelper.DuplicateRecord(txtFirstName.Text.Trim()));
                        isValidated = SetErrorMessage(txtLastName, MessageHelper.DuplicateRecord(txtLastName.Text));

                        return(isValidated);
                    }
                }
            }

            return(isValidated);
        }
Beispiel #30
0
        private void ShowContextMenu(object sender, int x_pos = -1, int y_pos = -1)
        {
            if (((DataGridView)sender).Rows.Count == 0)
            {
                return;
            }

            int row_index = ((DataGridView)sender).CurrentCell.RowIndex;

            EventCalendar event_calendar = null;
            var           ev             = ((DataGridView)sender).Rows[row_index].Cells[0].Value;

            if (ev != null)
            {
                event_calendar = ev as EventCalendar;
            }

            ContextMenu cm = new ContextMenu();

            MenuItem mnu_add = new MenuItem();

            mnu_add.Text   = "เพิ่ม";
            mnu_add.Click += delegate
            {
                DateEventWindow date_event = new DateEventWindow(this, true);
                date_event.ShowDialog();
            };
            cm.MenuItems.Add(mnu_add);

            MenuItem mnu_edit = new MenuItem();

            mnu_edit.Text    = "แก้ไข";
            mnu_edit.Enabled = event_calendar != null ? true : false;
            mnu_edit.Click  += delegate
            {
                DateEventWindow date_event = new DateEventWindow(this, true, event_calendar);
                date_event.ShowDialog();
            };
            cm.MenuItems.Add(mnu_edit);

            MenuItem mnu_copy = new MenuItem();

            mnu_copy.Text    = "คัดลอกรายการนี้ไปยังวันที่ ...";
            mnu_copy.Enabled = event_calendar != null ? true : false;
            mnu_copy.Click  += delegate
            {
                DateSelectorDialog ds = new DateSelectorDialog(this.date.Value);
                if (ds.ShowDialog() == DialogResult.OK)
                {
                    this.DoCopy(ds.selected_date, (EventCalendar)this.dgv.Rows[row_index].Cells[0].Value);
                }
            };
            cm.MenuItems.Add(mnu_copy);

            MenuItem mnu_delete = new MenuItem();

            mnu_delete.Text    = "ลบ";
            mnu_delete.Enabled = event_calendar != null ? true : false;
            mnu_delete.Click  += delegate
            {
                if (MessageAlert.Show(StringResource.CONFIRM_DELETE, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
                {
                    bool             delete_success = false;
                    string           err_msg        = "";
                    BackgroundWorker worker         = new BackgroundWorker();
                    worker.DoWork += delegate
                    {
                        CRUDResult   delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "eventcalendar/delete&id=" + ((EventCalendar)this.dgv.Rows[row_index].Cells[0].Value).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)
                        {
                            this.RefreshData();
                            this.RefreshView();
                        }
                        else
                        {
                            this.RefreshData();
                            this.RefreshView();
                            MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                        }
                    };
                    worker.RunWorkerAsync();
                }
            };
            cm.MenuItems.Add(mnu_delete);

            if (x_pos < 0 || y_pos < 0)
            {
                x_pos = ((DataGridView)sender).GetCellDisplayRectangle(2, row_index, true).X;
                y_pos = ((DataGridView)sender).GetCellDisplayRectangle(2, row_index, true).Y;
            }

            cm.Show((DataGridView)sender, new Point(x_pos, y_pos));
        }