private void bSave_Click(object sender, EventArgs e)
        {
            if (Check())
            {
                string   customer     = this.tbCustomer.Text;
                short    order        = Convert.ToInt16(this.mtbOrder.Text);
                DateTime warrantyDate = DateTime.Now.Date;
                int      areaId       = (this.bBrigade.Tag as Brigade).AreaId;
                int      brigadeId    = (this.bBrigade.Tag as Brigade).Id;
                float    percent      = this._percent;

                Warranty warranty = new Warranty(customer, order, percent, warrantyDate, areaId, brigadeId);

                if (this._WarrantyId == 0)
                {
                    Databases.Tables.Warranties.Insert(warranty);
                    this._Warranty = warranty;
                }
                else
                {
                    if (!warranty.Equals(this._Warranty))
                    {
                        this._Warranty.Update(warranty);
                    }
                }

                List <Executor> executors = new List <Executor>();
                List <Labor>    labors    = new List <Labor>();
                List <Position> positions = new List <Position>();

                foreach (DataGridViewRow executorsRow in this.ctrlExecutors.dgvItems.Rows)
                {
                    if (executorsRow.Cells["ExecutorId"].Value != null)
                    {
                        int  executorId   = Convert.ToInt32(executorsRow.Cells["ExecutorId"].Value);
                        int  personId     = (executorsRow.Cells["PersonCode"].Tag as Person).Id;
                        int  professionId = (executorsRow.Cells["ProfessionCode"].Tag as PersonProfession).ProfessionId;
                        byte rank         = Convert.ToByte(executorsRow.Cells["Rank"].Value);

                        Executor executor = new Executor(this._WarrantyId, personId, professionId, rank);

                        if (executorId < 0)
                        {
                            Databases.Tables.Executors.Insert(executor);
                            executors.Add(executor);
                        }
                        else if (executorId > 0)
                        {
                            Databases.Tables.Executors[executorId].Update(executor);
                            executors.Add(executor);
                        }
                    }
                }

                foreach (DataGridViewRow laborsRow in this.ctrlLabors.dgvItems.Rows)
                {
                    if (laborsRow.Cells["LaborId"].Value != null)
                    {
                        int      laborId   = Convert.ToInt32(laborsRow.Cells["LaborId"].Value);
                        DateTime laborDate = Convert.ToDateTime(laborsRow.Cells["LaborDate"].Value).Date;
                        float    hours     = Convert.ToSingle(laborsRow.Cells["Hours"].Value);

                        Labor labor = new Labor(this._WarrantyId, laborDate, hours);

                        if (laborId < 0)
                        {
                            Databases.Tables.Labors.Insert(labor);
                            labors.Add(labor);
                        }
                        else if (laborId > 0)
                        {
                            Databases.Tables.Labors[laborId].Update(labor);
                            labors.Add(labor);
                        }
                    }
                }

                foreach (DataGridViewRow positionsRow in this.ctrlPositions.dgvItems.Rows)
                {
                    if (positionsRow.Cells["Id"].Value != null)
                    {
                        int    positionId = Convert.ToInt32(positionsRow.Cells["Id"].Value);
                        string title      = positionsRow.Cells["Title"].Value.ToString();
                        string draw       = positionsRow.Cells["Draw"].Value.ToString();
                        string matherial  = positionsRow.Cells["Matherial"].Value.ToString();
                        int    number     = Convert.ToInt32(positionsRow.Cells["Number"].Value);
                        float  mass       = Convert.ToSingle(positionsRow.Cells["Mass"].Value);
                        float  norm       = Convert.ToSingle(positionsRow.Cells["Norm"].Value);
                        float  price      = Convert.ToSingle(positionsRow.Cells["Price"].Value);

                        Position position = new Position(this._WarrantyId, title, draw, matherial, number, mass, norm, price);

                        if (positionId < 0)
                        {
                            Databases.Tables.Positions.Insert(position);
                            positions.Add(position);
                        }
                        else if (positionId > 0)
                        {
                            Databases.Tables.Positions[positionId].Update(position);
                            positions.Add(position);
                        }
                    }
                }

                if (this._Warranty != null)
                {
                    foreach (Executor executor in this._Warranty.Executors.ToList().Except(executors.AsEnumerable()))
                    {
                        executor.Delete();
                    }

                    foreach (Position position in this._Warranty.Positions.ToList().Except(positions.AsEnumerable()))
                    {
                        position.Delete();
                    }
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }