Пример #1
0
        private void OnSaveInfo()
        {
            try
            {
                MethodInvoker method = delegate
                {
                    _giaVonDichVu.ServiceGUID = Guid.Parse(cboService.SelectedValue.ToString());
                    _giaVonDichVu.GiaVon      = (double)numGiaBan.Value;
                    _giaVonDichVu.NgayApDung  = dtpkNgayApDung.Value;
                    _giaVonDichVu.Status      = (byte)Status.Actived;

                    if (_isNew)
                    {
                        _giaVonDichVu.CreatedDate = DateTime.Now;
                        _giaVonDichVu.CreatedBy   = Guid.Parse(Global.UserGUID);
                    }
                    else
                    {
                        _giaVonDichVu.UpdatedDate = DateTime.Now;
                        _giaVonDichVu.UpdatedBy   = Guid.Parse(Global.UserGUID);
                    }

                    Result result = GiaVonDichVuBus.InsertGiaVonDichVu(_giaVonDichVu);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("GiaVonDichVuBus.InsertGiaVonDichVu"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.InsertGiaVonDichVu"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    }
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }