Ejemplo n.º 1
0
        private void GenerateItemsConfigs()
        {
            for (var i = 0; i < NumberOfConfigs; i++)
            {
                var atype = new ItemType
                {
                    Item_Type_Description = $"test {i}",
                    Item_Type_Name        = $"test {i}"
                };
                ItemTypeMgmt.AddItemType(atype);

                var aCategory = new ItemCategory
                {
                    Item_Category_Description = $"test {i}",
                    Item_Category_Name        = $"test {i}"
                };
                ItemCategoryMgmt.AddItemCategory(aCategory);

                var aVendors = new Vendors
                {
                    Vendor_Company    = $"test {i}",
                    Vendor_Email      = $"test {i}",
                    Vendor_Location   = $"test {i}",
                    Vendor_Name       = $"test {i}",
                    Vendor_Phone1     = "000",
                    Vendor_Phone2     = "222",
                    Vendor_Start_Date = "1/1/2009"
                };
                VendorsMgmt.AddVendor(aVendors);
            }
        }
Ejemplo n.º 2
0
        private void AddTypeBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                {
                    Nullable <int> Check = ItemTypeMgmt.IsTypeUsedByName(NameTxtBox.Text);
                    if (Check == 10)
                    {
                        ItemType aItemType = new ItemType();
                        aItemType.Item_Type_Name        = NameTxtBox.Text;
                        aItemType.Item_Type_Description = DescriptionTxtBox.Text;
                        if (!ItemTypeMgmt.AddItemType(aItemType))
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + "\nCannot Add Item Type\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    else if (Check == 5)
                    {
                        MessageBox.Show(MsgTxt.ItemTypeTxt + "\n" + NameTxtBox.Text + "\n" + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (Check == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error :Connection Problem In[AddTypeBtn_Click]  \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                    {
                        DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        DescriptionTxtBox.Focus();
                    }
                    else
                    {
                        DescriptionTxtBox.BackColor = DescBGColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text))
                    {
                        NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        NameTxtBox.Focus();
                    }
                    else
                    {
                        NameTxtBox.BackColor = NameBGColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddCategoryBtn_Click] -  \nException:\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }