private bool insertMaterial(string category, string itemCode, string itemName)
        {
            materialBLL uMaterial   = new materialBLL();
            materialDAL dalMaterial = new materialDAL();

            //Add data
            uMaterial.material_cat       = category;
            uMaterial.material_code      = itemCode;
            uMaterial.material_name      = itemName;
            uMaterial.material_zero_cost = 0;

            bool success = dalMaterial.Insert(uMaterial);

            //If the data is successfully inserted then the value of success will be true else false
            if (success == true)
            {
                //Data Successfully Inserted
                //MessageBox.Show("Material successfully created");
                insertItem(category, itemCode, itemName);
            }
            else
            {
                //Failed to insert data
                dalMaterial.Delete(uMaterial);
                MessageBox.Show("Failed to add new material");
            }

            return(success);
        }
        private void insertMaterial()
        {
            //Add data
            uMaterial.material_cat  = cmbCat.Text;
            uMaterial.material_code = txtItemCode.Text;
            uMaterial.material_name = txtItemName.Text;

            if (cbZeroCost.Checked)
            {
                uMaterial.material_zero_cost = 1;
            }
            else
            {
                uMaterial.material_zero_cost = 0;
            }

            bool success = dalMaterial.Insert(uMaterial);

            //If the data is successfully inserted then the value of success will be true else false
            if (success == true)
            {
                //Data Successfully Inserted
                //MessageBox.Show("Material successfully created");
                insertItem();
                this.Close();
            }
            else
            {
                //Failed to insert data
                dalMaterial.Delete(uMaterial);
                MessageBox.Show("Failed to add new material");
            }
        }
        private bool updateMaterial(string category, string itemCode, string itemName)
        {
            materialBLL uMaterial   = new materialBLL();
            materialDAL dalMaterial = new materialDAL();

            //Update data
            uMaterial.material_cat  = category;
            uMaterial.material_code = itemCode;
            uMaterial.material_name = itemName;

            uMaterial.material_zero_cost = 0;

            bool success = false;

            if (tool.IfMaterialExists(itemCode))
            {
                success = dalMaterial.Update(uMaterial);
            }
            else
            {
                success = dalMaterial.Insert(uMaterial);
            }

            if (success == true)
            {
                //data updated successfully
                //MessageBox.Show("Material successfully updated ");
                updateItem(category, itemCode, itemName);
            }
            else
            {
                //failed to update user
                MessageBox.Show("Failed to updated material");
            }
            return(success);
        }