Exemple #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);
            }
        }
Exemple #2
0
        private void AddVendorBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckRequiredFields())
                {
                    if (!VendorsMgmt.IsVendorExist(NameTxtBox.Text))
                    {
                        Vendors aVendor = new Vendors();
                        aVendor.Vendor_Name     = NameTxtBox.Text;
                        aVendor.Vendor_Email    = EmailTxtBox.Text;
                        aVendor.Vendor_Location = LocationTxtBox.Text;
                        aVendor.Vendor_Phone1   = Phone1TxtBox.Text;
                        aVendor.Vendor_Phone2   = Phone2TxtBox.Text;
                        aVendor.Vendor_Company  = CompanyTxtBox.Text;

                        DateTime aDate = DateTime.Now;
                        aVendor.Vendor_Start_Date = aDate.Date.ToShortDateString();

                        if (VendorsMgmt.AddVendor(aVendor))
                        {
                            int VendorID = VendorsMgmt.SelectVendorIDByName(aVendor.Vendor_Name);

                            if (VendorID == 0)
                            {
                                MessageBox.Show(MsgTxt.UnexpectedError + " \n [DataBase ERROR 1 IN[AddVendorBtn_Click] VendorID=0", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }

                            if (!VendorsAccountsMgmt.InserVendorAccount(VendorID))
                            {
                                MessageBox.Show(MsgTxt.UnexpectedError + " \n [DataBase ERROR 2 IN[AddVendorBtn_Click] ", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            else
                            {
                                int AccountID = int.Parse(VendorsAccountsMgmt.SelectVendorAccountRowByVendorID(VendorID)["ID"].ToString());
                                VendorsAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, double.Parse(OpenBalTxtBox.Text));
                            }

                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);

                            DialogResult ret;
                            ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                            if (ret == DialogResult.Yes)
                            {
                                foreach (TextBox aTextBox in this.CustomerInfoGB.Controls.OfType <TextBox>())
                                {
                                    aTextBox.Text = "";
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + " \n [DataBase ERROR 3 IN[AddVendorBtn_Click]", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.VendorTxt + " [ " + NameTxtBox.Text + " ] " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddVendorBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }