예제 #1
0
        private void OnSaveInfo()
        {
            try
            {
                _diaChiCongTy.MaCongTy = txtMaCongTy.Text;
                _diaChiCongTy.DiaChi   = txtDiaChi.Text;
                _diaChiCongTy.Status   = (byte)Status.Actived;

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

                Result result = DiaChiCongTyBus.InsertDiaChiCongTy(_diaChiCongTy);
                if (!result.IsOK)
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("DiaChiCongTyBus.InsertDiaChiCongTy"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("DiaChiCongTyBus.InsertDiaChiCongTy"));
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }
예제 #2
0
        private void OnDelete()
        {
            if (_dataSource == null)
            {
                return;
            }
            //UpdateChecked();
            List <string>  deletedSympList = new List <string>();
            List <DataRow> deletedRows     = new List <DataRow>();
            DataTable      dt = _dataSource;//dgSymptom.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    deletedSympList.Add(row["DiaChiCongTyGUID"].ToString());
                    deletedRows.Add(row);
                }
            }

            if (deletedSympList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những địa chỉ mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = DiaChiCongTyBus.DeleteDiaChiCongTy(deletedSympList);
                    if (result.IsOK)
                    {
                        foreach (DataRow row in deletedRows)
                        {
                            _dictDiaChiCongTy.Remove(row["DiaChiCongTyGUID"].ToString());
                            _dataSource.Rows.Remove(row);
                        }

                        OnSearchDiaChiCongTy();
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("DiaChiCongTyBus.DeleteDiaChiCongTy"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("DiaChiCongTyBus.DeleteDiaChiCongTy"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những địa chỉ cần xóa.", IconType.Information);
            }
        }
예제 #3
0
        private void OnDisplayDiaChiCongTyList()
        {
            Result result = DiaChiCongTyBus.GetDanhSachDiaChiCongTy();

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    _dataSource = result.QueryResult as DataTable;

                    if (_dictDiaChiCongTy == null)
                    {
                        _dictDiaChiCongTy = new Dictionary <string, DataRow>();
                    }
                    foreach (DataRow row in _dataSource.Rows)
                    {
                        string diaChiCongTyGUID = row["DiaChiCongTyGUID"].ToString();
                        _dictDiaChiCongTy.Add(diaChiCongTyGUID, row);
                    }

                    OnSearchDiaChiCongTy();
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("DiaChiCongTyBus.GetDanhSachDiaChiCongTy"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("DiaChiCongTyBus.GetDanhSachDiaChiCongTy"));
            }
        }
예제 #4
0
        private bool CheckInfo()
        {
            if (txtMaCongTy.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập mã công ty.", IconType.Information);
                txtMaCongTy.Focus();
                return(false);
            }

            if (txtDiaChi.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập địa chỉ công ty.", IconType.Information);
                txtDiaChi.Focus();
                return(false);
            }

            string diaChiCongTyGUID = _isNew ? string.Empty : _diaChiCongTy.DiaChiCongTyGUID.ToString();
            Result result           = DiaChiCongTyBus.CheckMaCongTyExistCode(diaChiCongTyGUID, txtMaCongTy.Text);

            if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
            {
                if (result.Error.Code == ErrorCode.EXIST)
                {
                    MsgBox.Show(this.Text, "Mã công ty này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information);
                    txtMaCongTy.Focus();
                    return(false);
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("DiaChiCongTyBus.CheckMaCongTyExistCode"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("DiaChiCongTyBus.CheckMaCongTyExistCode"));
                return(false);
            }

            return(true);
        }