private void DeleteButton_Click(object sender, EventArgs e)
 {
     try
     {
         EstateObjects.Delete(Id, SqlConnection);
         MessageBox.Show("Запись удалена");
         this.Close();
     }
     catch
     {
         MessageBox.Show("невозможно удалить");
     }
 }
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         ConvertData();
         EstateObjects.Insert(SqlConnection, Status, OwnerId, Price, Address, District, Description, RealtyTypes, TradeTypes, Area, Rooms, LandDescription, LandArea);
         MessageBox.Show("Запись добавлена");
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 private void acceptButton_Click(object sender, EventArgs e)
 {
     try
     {
         ConvertData();
         Trades.CreateTrade(SqlConnection, Id, CurrentUser.ManagerId);
         EstateObjects.UpdateStatus(SqlConnection, Id, 3);
         Trades.UpdateLinksWithTrade(SqlConnection);
         MessageBox.Show("Заявка одобрена");
         this.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Очевидно, другой менеджер уже успел рассмотреть эту заявку. Обновите страницу и рассмотрите другие заявки.");
     }
 }
        private void CreateItemInfoForm(int id)
        {
            string statusComboBox     = "";
            string ownerComboBox      = "";
            string priceTextBox       = "";
            string addressTextBox     = "";
            string districtComboBox   = "";
            string descriptionTextBox = "";
            string realtyTypeComboBox = "";
            string tradeTypeComboBox  = "";
            string areaTextBox        = "";
            string roomsTextBox       = "";
            string landTextBox        = "";
            string landAreaTextBox    = "";

            EstateObjects.CreateItemInfo(SqlConnection, id,
                                         out statusComboBox, out ownerComboBox, out priceTextBox,
                                         out addressTextBox, out districtComboBox, out descriptionTextBox,
                                         out realtyTypeComboBox, out tradeTypeComboBox, out areaTextBox,
                                         out roomsTextBox, out landTextBox, out landAreaTextBox);


            StatusComboBox.Text     = statusComboBox;
            OwnerComboBox.Text      = ownerComboBox;
            PriceTextBox.Text       = priceTextBox;
            AddressTextBox.Text     = addressTextBox;
            DistrictComboBox.Text   = districtComboBox;
            DescriptionTextBox.Text = descriptionTextBox;
            RealtyTypeComboBox.Text = realtyTypeComboBox;
            TradeTypeComboBox.Text  = tradeTypeComboBox;
            AreaTextBox.Text        = areaTextBox;
            RoomsTextBox.Text       = roomsTextBox;
            LandTextBox.Text        = landTextBox;
            LandAreaTextBox.Text    = landAreaTextBox;

            images = Images(id);
            if (images.Count > 0)
            {
                AllowPrevNextImageButtons();
                pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;

                pictureBox1.Image = Image.FromFile(images[0]);
            }

            Block();
        }
 private void RefuseButton_Click(object sender, EventArgs e)
 {
     try
     {
         ConvertData();
         if (Trades.FirstManager(SqlConnection, Id))
         {
             EstateObjects.UpdateStatus(SqlConnection, Id, 1);
             int linkid = Trades.FindLinkId(SqlConnection, Id);
             Trades.DeleteLink(SqlConnection, linkid);
             MessageBox.Show("Заявка отклонена");
         }
         this.Close();
     }
     catch (Exception t)
     {
         MessageBox.Show(t.ToString());
     }
 }
Esempio n. 6
0
        public static void DeleteTrade(SqlConnection sqlConnection, int linkId)
        {
            int[]      tradeItemId = TradeItemId(sqlConnection, linkId);
            SqlCommand command     = sqlConnection.CreateCommand();
            string     strCommand  = string.Format("DELETE FROM Trades WHERE id = @deleteid");

            command.CommandText = strCommand;
            command.Parameters.Add("deleteid", SqlDbType.NVarChar).Value = tradeItemId[0];
            sqlConnection.Open();
            try
            {
                command.ExecuteNonQuery();
            }
            finally
            {
                sqlConnection.Close();
            }
            EstateObjects.UpdateStatus(sqlConnection, tradeItemId[1], 1);
        }
        private static void GetCellValue(Excel.Worksheet sheet, SqlConnection sqlConnection)
        {
            int lastRow = sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; // Последняя заполненная строка

            string[,] mas = new string[lastRow, 4];                                          // Выделяем память под массив строк

            mas = ArrRange(2, 1, lastRow, 12, sheet);                                        // Получаем данные с листа

            for (int l = 0; l < lastRow - 1; l++)                                            // Заполняем массив
            {
                int    statusId        = Convert.ToInt32(mas[l, 0]);
                int    ownerId         = Convert.ToInt32(mas[l, 1]);
                float  price           = (float)Convert.ToDouble(mas[l, 2]);
                string addres          = mas[l, 3];
                int    district        = Convert.ToInt32(mas[l, 4]);
                string description     = mas[l, 5];
                int    realtytype      = Convert.ToInt32(mas[l, 6]);
                int    tradetype       = Convert.ToInt32(mas[l, 7]);
                float  area            = (float)Convert.ToDouble(mas[l, 8]);
                byte   rooms           = Convert.ToByte(mas[l, 9]);
                string landdescription = mas[l, 10];
                float  landarea        = (float)Convert.ToDouble(mas[l, 11]);
                try
                {
                    if (realtytype == 3)
                    {
                        EstateObjects.Insert(sqlConnection, statusId, ownerId, price, addres, district, description, realtytype, tradetype, area, rooms, landdescription, landarea);
                    }
                    if (realtytype == 1)
                    {
                        EstateObjects.Insert(sqlConnection, statusId, ownerId, price, addres, district, description, realtytype, tradetype, area, rooms);
                    }
                    if (realtytype == 2)
                    {
                        EstateObjects.Insert(sqlConnection, statusId, ownerId, price, addres, district, description, realtytype, tradetype, area);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
Esempio n. 8
0
        public static void FinalTrade(SqlConnection sqlConnection, int item, int pType, int pInstrument)
        {
            //SqlCommand command = sqlConnection.CreateCommand();
            //string strcom;
            //strcom = string.Format("UPDATE EstateObjects SET statusid=4 WHERE Id=@item");
            //command.CommandText = strcom;
            //command.Parameters.AddWithValue("@item", item);

            //sqlConnection.Open();
            //try
            //{
            //    command.ExecuteNonQuery();
            //}
            //finally
            //{
            //    sqlConnection.Close();
            //}
            EstateObjects.UpdateStatus(sqlConnection, item, 4);
            UpdateTrade(sqlConnection, item, pType, pInstrument);
        }
 private void BuyButton_Click(object sender, EventArgs e)
 {
     try
     {
         ConvertData();
         EstateObjects.UpdateStatus(SqlConnection, Id, 2);
         try
         {
             Trades.CreateClientObjectLink(SqlConnection, CurrentUser.ClientId, Id);
             MessageBox.Show("Заявка подана на рассмотрение");
             this.Close();
         }
         catch (Exception tt)
         {
             MessageBox.Show("К сожалению, кто-то только что оформил заявку на этот объект. Попробуйте выбрать другой объект в нашем каталоге.");
         }
     }
     catch (Exception u)
     {
         MessageBox.Show(u.ToString());
     }
 }