private async void cbSearchContract_SelectionChangeCommitted(object sender, EventArgs e)
        {
            mlLabel11.Text = ((CommonContract)cbSearchContract.SelectedItem).CompanyName;
            mlLabel12.Text = ((CommonContract)cbSearchContract.SelectedItem).VatNumber;
            mlLabel14.Text = ((CommonContract)cbSearchContract.SelectedItem).Bulstat;
            mlLabel16.Text = ((CommonContract)cbSearchContract.SelectedItem).Address;
            List <CommonMol> mols = await SAOwner.getAllMols(((CommonContract)cbSearchContract.SelectedItem).PartnerId);

            CommonMol mol = mols.Count == 0 ? new CommonMol() : mols.First();

            mlLabel13.Text = mol.FirstName + " " + mol.LastName;
        }
Beispiel #2
0
//        private void tbSearchContracts_KeyDown(object sender, KeyEventArgs e)
//        {
//            if (e.KeyCode != Keys.Enter)
//            {
//                return;
//            }
//
//            LoadDataContracts();
//        }

        private async void btnEditContract_Click(object sender, EventArgs e)
        {
            if (dgvContracts.SelectedRows.Count == 1 && dgvContracts.SelectedRows[0] != null)
            {
                CommonContract   selectedItem = (CommonContract)dgvContracts.SelectedRows[0].DataBoundItem;
                List <CommonMol> mols         = await SAOwner.getAllMols(selectedItem.PartnerId);

                CommonMol           mol  = mols.Count == 0 ? new CommonMol() : mols.First();
                AddEditContractForm form = new AddEditContractForm(selectedItem, mol);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    LoadDataContracts();
                }
            }
        }
Beispiel #3
0
        public async void LoadMolList()
        {
            AllMols = await SAOwner.getAllMols(DataHolder.Owner.OwnerId);

            NonPrimeryMols.Clear();

            List <CommonMol> primeryMol = new List <CommonMol>();

            foreach (var mol in AllMols)
            {
                if (mol.IsPrimery)
                {
                    primeryMol.Add(mol);
                    PrimeryMol = mol;
                }
                else
                {
                    NonPrimeryMols.Add(mol);
                }
            }
            dgvMol.DataSource        = null;
            dgvMol.DataSource        = NonPrimeryMols;
            dgvPrimaryMol.DataSource = primeryMol;
        }
        private async void cbSearchOrders_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (trigger)
            {
                if (Settings.Default.ItemMapping)
                {
                    KeyValuePair <Guid, List <CommonItem> > mappedItems = MappedItems.FirstOrDefault(p => p.Key == ((CommonContract)cbSearchOrders.SelectedItem).PartnerId);
                    cbSearchGoodsOrders.DataSource = mappedItems.Value;
                }

                companyNameHidden.Text = ((CommonContract)cbSearchOrders.SelectedItem).CompanyName;
                lbVatHidden.Text       = ((CommonContract)cbSearchOrders.SelectedItem).VatNumber;
                lbBulstatHidden.Text   = ((CommonContract)cbSearchOrders.SelectedItem).Bulstat;
                lbAddressHidden.Text   = ((CommonContract)cbSearchOrders.SelectedItem).Address;
                List <CommonMol> mols = await SAOwner.getAllMols(((CommonContract)cbSearchOrders.SelectedItem).PartnerId);

                CommonMol mol = mols.Count == 0 ? new CommonMol() : mols.First();
                lbMolHidden.Text = mol.FirstName + " " + mol.LastName;
            }
            else
            {
                trigger = true;
            }
        }
Beispiel #5
0
        private async void btnLogin_Click(object sender, EventArgs e)
        {
            if (Trigger)
            {
                Trigger = false;
                DataHolder.Init();
                switch (cbLanguage.SelectedValue.ToString())
                {
                case "Български":
                    DataHolder.UserCulture = new CultureInfo("bg-BG");
                    break;

                case "English":
                    DataHolder.UserCulture = new CultureInfo("en-US");
                    break;

                default:
                    DataHolder.UserCulture = new CultureInfo("en-US");
                    break;
                }

                if (!string.IsNullOrEmpty(tbUsername.Text) && !string.IsNullOrEmpty(tbPassword.Text))
                {
                    DataHolder.ServerAddress = cbServer.Text;
                    CommonUser user = await SAUsers.Login(tbUsername.Text, tbPassword.Text);

                    if (user != null)
                    {
                        DataHolder.CurrnetUserId   = user.UserId;
                        DataHolder.OwnerId         = user.OwnerId;
                        DataHolder.Username        = user.Username;
                        DataHolder.UserType        = user.Role;
                        DataHolder.UserPermissions = user.Permissions;
                        DataHolder.Settings        = await SASettings.getUserSettings();

                        List <CommonMol> allMols = await SAOwner.getAllMols(user.OwnerId);

                        foreach (var mol in allMols)
                        {
                            if (mol.IsPrimery)
                            {
                                DataHolder.PrimeryMol = mol;
                                break;
                            }
                        }

                        MainForm form = new MainForm();
                        Hide();

                        if (form.ShowDialog() == DialogResult.Cancel)
                        {
                            Trigger            = true;
                            labelError.Visible = false;
                            Show();
                            tbPassword.Text = string.Empty;
                            tbUsername.Text = DataHolder.Username;

                            //clear previus data
                            DataHolder.CurrnetUserId   = Guid.Empty;
                            DataHolder.OwnerId         = Guid.Empty;
                            DataHolder.ServerAddress   = string.Empty;
                            DataHolder.Username        = string.Empty;
                            DataHolder.UserType        = 99;
                            DataHolder.UserCulture     = new CultureInfo("en-US");
                            DataHolder.PrimeryMol      = null;
                            DataHolder.UserPermissions = "";
                            DataHolder.Settings        = new CommonSettings();
                        }
                    }
                    else
                    {
                        labelError.Visible = true;
                        labelError.Text    = DataHolder.GetString("invalid_username_or_password");
                        Trigger            = true;
                    }
                }
                else
                {
                    labelError.Visible = true;
                    labelError.Text    = DataHolder.GetString("invalid_username_or_password");
                    Trigger            = true;
                }
            }
        }