Visual Studio dasturining Visual C++ dasturlash tilida kichik loyihalar yaratish Loyiha bu
Download 1.55 Mb.
|
Visual Studio dasturida MB ni vizuallashtirish
Команда->Parameters->AddWithValue("@Id",Id); Команда->ExecuteNonQuery(); MessageBox::Show("Talabalar jadvalining ma'lumotlari muaafaqiyatli yangilandi");} //else{MessageBox::Show("Ma'lumotlar o'zgartirilmadi");} catch(Exception^ vaziyat) {MessageBox::Show("Talabalar jadvalini yangilashda xatolik yuz berdi");} } else if(h==2) { try{ Команда = gcnew OleDb::OleDbCommand("Select * From [Qarindoshlar]", con); Команда->CommandText = "UPDATE Qarindoshlar SET Fam = @Fam, Ismi = @Ism, Sharfi = @Sharf, Yashash_manzili = @Yashash_manzili, Tugilgan_sana = @Tugilgan_sana, Qarindoshlik_turi = @Qarindoshlik_turi,"+ "Id_nomeri = @Id_nomeri, Ish_joyi = @Ish_joyi, Telefoni = @Telefoni WHERE id = @Id"; Команда->Parameters->AddWithValue("@Fam",textBox1->Text); Команда->Parameters->AddWithValue("@Ism",textBox2->Text); Команда->Parameters->AddWithValue("@Sharf",textBox3->Text); Команда->Parameters->AddWithValue("@Yashash_manzili",textBox4->Text); Команда->Parameters->AddWithValue("@Tugilgan_sana",textBox5->Text); Команда->Parameters->AddWithValue("@Qarindoshlik_turi",textBox6->Text); Команда->Parameters->AddWithValue("@Id_nomeri",textBox7->Text); Команда->Parameters->AddWithValue("@Ish_joyi",textBox8->Text); Команда->Parameters->AddWithValue("@Telefoni",textBox9->Text); Команда->Parameters->AddWithValue("@Id",Id); Команда->ExecuteNonQuery(); MessageBox::Show("Qarindoshlar jadvalining ma'lumotlari muaafaqiyatli yangilandi");} //else{MessageBox::Show("Ma'lumotlar o'zgartirilmadi");} catch(Exception^ vaziyat) {MessageBox::Show("Qarindoshlar jadvalini yangilashda xatolik yuz berdi");} } TTJ_3 = gcnew TTJ_sinf(); bool s; TTJ_3->ShowRecord(dataGridView1,"Select * From Talabalar"); delete TTJ_3; } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { ornatish(Kornat); } private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) { OpenFileDialog^ och=gcnew OpenFileDialog(); och->Title="Rasmni tanlash oynasi"; och->Filter="Image File(*.png; *.jpg; *.bmp; *.gif)|*.png; *.jpg; *.bmp; *.gif"; och->ShowDialog(); //if( DialogResult.Equals(och->ShowDialog) ) try{ pictureBox1->Image = gcnew Bitmap(och->FileName);} catch(Exception^ vaziyat){ MessageBox::Show("Rasm tanlamadingiz"); } } public: System::Void Saqlash(){ OleDbConnection^ con = gcnew OleDbConnection("Data Source=\"TTJ.mdb\";User " + "ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";"); con->Open(); try{ //if(DialogResult.Equals( MessageBox::Show("Ma'lumotlarni yangilash", "Haqiqatdan ham ushbu talabani yangilamoqchimisiz?", //MessageBoxButtons::OKCancel, MessageBoxIcon::Information))!=0) Команда = gcnew OleDb::OleDbCommand("Select * From [Talabalar]", con); Команда->CommandText = "INSERT INTO Talabalar (Fam, Ism, Sharf, Guruh, Xona_nomeri, Blok_nomi, Qavat_nomeri, Telefoni, Tugilgan_viloyati, Pasport_seriasi, "+ " Tugilgan_Sana, Pasport_nomeri, Tugilgan_yili, Tugilgan_oyi, Tugilgan_kuni, Fakulteti, Yonalishi, Tugilgan_tumani,"+ " Jinsi, Lavozim, Yashash_manzili, Bosqich, Rasm) VALUES(@Fam, @Ism, @Sharf, @Guruh, @Xona_nomeri, @Blok_nomi, @Qavat_nomeri, @Telefoni, @Tugilgan_viloyati, @Pasport_seriasi, "+ " @Tugilgan_Sana, @Pasport_nomeri, @Tugilgan_yili, @Tugilgan_oyi, @Tugilgan_kuni, @Fakulteti, @Yonalishi, @Tugilgan_tumani,"+ " @Jinsi, @Lavozim, @Yashash_manzili, @Bosqich, @Rasm)"; Команда->Parameters->AddWithValue("@Fam",textBox1->Text); Команда->Parameters->AddWithValue("@Ism",textBox2->Text); Команда->Parameters->AddWithValue("@Sharf",textBox3->Text); Команда->Parameters->AddWithValue("@Guruh",textBox4->Text); Команда->Parameters->AddWithValue("@Xona_nomeri",textBox5->Text); Команда->Parameters->AddWithValue("@Blok_nomi",textBox6->Text); Команда->Parameters->AddWithValue("@Qavat_nomeri",textBox7->Text); Команда->Parameters->AddWithValue("@Telefoni",textBox8->Text); Команда->Parameters->AddWithValue("@Tugilgan_viloyati",textBox9->Text); Команда->Parameters->AddWithValue("@Pasport_seriasi",textBox10->Text); Команда->Parameters->AddWithValue("@Tugilgan_Sana",textBox11->Text); Команда->Parameters->AddWithValue("@Pasport_nomeri",textBox13->Text); Команда->Parameters->AddWithValue("@Tugilgan_yili",textBox14->Text); Команда->Parameters->AddWithValue("@Tugilgan_oyi",textBox15->Text); Команда->Parameters->AddWithValue("@Tugilgan_kuni",textBox16->Text); Команда->Parameters->AddWithValue("@Fakulteti",textBox20->Text); Команда->Parameters->AddWithValue("@Yonalishi",textBox21->Text); Команда->Parameters->AddWithValue("@Tugilgan_tumani",textBox22->Text); Команда->Parameters->AddWithValue("@Jinsi",textBox23->Text); Команда->Parameters->AddWithValue("@Lavozim",textBox24->Text); Команда->Parameters->AddWithValue("@Yashash_manzili",textBox12->Text); Команда->Parameters->AddWithValue("@Bosqich",textBox17->Text); Команда->Parameters->AddWithValue("@Rasm",SaveRasm()); Команда->ExecuteNonQuery(); MessageBox::Show("Talabalar jadvaliga yangi ma'lumotlar kiritildi");} //else{MessageBox::Show("Ma'lumotlar o'zgartirilmadi");} catch(Exception^ vaziyat) {MessageBox::Show(Convert::ToString(vaziyat));} // //auto Подключение = gcnew OleDbConnection( //"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TTJ.mdb"); //// Открытие подключения: //Подключение->Open(); //OleDb::OleDbDataAdapter ^ Adapter; // //// Создание экземпляра объекта Command с заданием SQL-запроса: //auto Команда = gcnew OleDbCommand( //"INSERT INTO [Talabalar] (Fam, Ism, Sharf, Guruh, Bosqich,Tugilgan_viloyati, Pasport_seriasi,"+ //"Tugilgan_Sana, Pasport_nomeri, Xona_nomeri, Blok_nomi, Qavat_nomeri, Lavozim, Telefoni, Tugilgan_yili,"+ //"Tugilgan_oyi, Tugilgan_kuni, Jinsi, Fakulteti, Yonalishi, Tugilgan_tumani, Yashash_manzili, Rasm) VALUES ('" // +textBox1->Text+"', '"+textBox2->Text+"', '"+textBox3->Text+"', '"+textBox4->Text+"', '"+textBox17->Text+ //"', '"+textBox9->Text+"', '"+textBox10->Text+"', '"+textBox11->Text+"', '"+textBox13->Text+ //"', '"+textBox5->Text+"', '"+textBox6->Text+"', '"+textBox7->Text+"', '"+textBox24->Text+ //"', '"+textBox8->Text+"', '"+textBox14->Text+"', '"+textBox15->Text+"', '"+textBox16->Text+ //"', '"+textBox23->Text+"', '"+textBox20->Text+"', '"+textBox21->Text+"', '"+textBox22->Text+ //"', '"+textBox12->Text+"', '"+SaveRasm()+"')"); // //// Для добавления записи в таблицу БД эта команда обязательна: ////Adapter->InsertCommand = Команда; //Команда->Connection = Подключение; //// Выполнение команды SQL: //Команда->ExecuteNonQuery(); //MessageBox::Show("Talabalr jadvaliga yangi ma'lumotlar yozildi"); //Команда->CommandText = "UPDATE Talabalar SET Rasm = @Rasm WHERE id = @Id"; // Команда->Parameters->AddWithValue("@Rasm",SaveRasm()); // Команда->Parameters->AddWithValue("@Id",Id); // //Команда->ExecuteNonQuery(); //Подключение->Close(); TTJ_3 = gcnew TTJ_sinf(); bool s; TTJ_3->ShowRecord(dataGridView1,"Select * From Talabalar"); delete TTJ_3; /* int rowToUpdate = Convert::ToInt32(dataGridView1->RowCount); MessageBox::Show( (rowToUpdate-1).ToString()); int id = Convert::ToInt32(dataGridView1->Rows[rowToUpdate-1]->Cells["id"]->Value); OleDbConnection^ con2 = gcnew OleDbConnection("Data Source=\"TTJ.mdb\";User " + "ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";"); con2->Open(); Команда = gcnew OleDb::OleDbCommand("Select * From [Talabalar]", con2); Команда->CommandText = "UPDATE Talabalar SET Rasm = @Rasm WHERE id = @id"; Команда->Parameters->AddWithValue("@Rasm",SaveRasm()); Команда->Parameters->AddWithValue("@id",id); Команда->ExecuteNonQuery(); MessageBox::Show("Talabalar jadvalining ma'lumotlari muaafaqiyatli yangilandi!!!!!!!!!!!!!!!"); */ //Application::Restart(); } void nol(){ textBox1->Text = " "; textBox2->Text = " "; textBox3->Text = " "; //textBox4->Text = "218-17"; //textBox5->Text = "207"; //textBox6->Text = "A,B,C"; //textBox7->Text = "2"; textBox8->Text = " "; textBox9->Text = " "; textBox10->Text = " "; //textBox11->Text = " "; textBox12->Text = " "; textBox13->Text = " "; textBox14->Text = " "; textBox15->Text = " "; //textBox16->Text = " "; textBox17->Text = " "; textBox20->Text = " "; textBox21->Text = " "; textBox22->Text = " "; textBox23->Text = " "; textBox24->Text = " "; } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { //Saqlash(); TTJ_3 = gcnew TTJ_sinf(); bool s; TTJ_3->ShowRecord(dataGridView1,"Select count (*) as soni From Talabalar Where Blok_nomi ='"+ textBox6->Text+"' AND Xona_nomeri ="+textBox5->Text); delete TTJ_3; int id = Convert::ToInt32(dataGridView1->Rows[0]->Cells["soni"]->Value); if(id<=2){ auto MBox = MessageBox::Show("3 - talabani qo'shasizmi? ", "3 talik xonami", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Exclamation); // YES — диалог; NO — выход; CANCEL - редактировать if (MBox == Windows::Forms::DialogResult::No) return; //if (MBox == Windows::Forms::DialogResult::Cancel){ this->Close();} if (MBox == Windows::Forms::DialogResult::Yes){ Saqlash();} } else {MessageBox::Show("3 tadan ortiq talaba qo'shish mumkin emas");} //int row_count =dataGridView1->Rows->GetR // label18->Text ="soni= "+ (id).ToString(); } private: System::Void Studentlarni_yangilash_Load(System::Object^ sender, System::EventArgs^ e) { nol(); //textBox11->Text = " "; } private: System::Void textBox11_TextChanged(System::Object^ sender, System::EventArgs^ e) { try{textBox16->Text = textBox11->Text->Substring(0,2); textBox15->Text = textBox11->Text->Substring(3,2); textBox14->Text = textBox11->Text->Substring(6,4); } catch(Exception^ vaz){} } private: System::Void textBox5_TextChanged(System::Object^ sender, System::EventArgs^ e) { try{ textBox7->Text = textBox5->Text->Substring(0,1);//Convert::ToString(textBox5->Text[0]); } catch(Exception^ vaz){} } private: System::Void textBox6_TextChanged(System::Object^ sender, System::EventArgs^ e) { int id; if(textBox6->Text=="A"){ textBox6->Text="A"; goto bir; } if(textBox6->Text=="B"){ textBox6->Text="B"; goto bir; } if(textBox6->Text=="V"){ textBox6->Text="V"; } else textBox6->Text=""; bir: id=2; } private: System::Void textBox4_TextChanged(System::Object^ sender, System::EventArgs^ e) { DateTime^ dd= DateTime::Now; String^ yil= Convert::ToString(dd); //label18->Text = yil->Substring(8,2); try{ //MessageBox::Show(textBox4->Text->Substring(4,2)); int a=Convert::ToInt32(textBox4->Text->Substring(4,2)); int b=Convert::ToInt32(yil->Substring(8,2)); if(a==b){textBox17->Text="1";} if(a+1==b){textBox17->Text="2";} if(a+2==b){textBox17->Text="3";} if(a+3==b){textBox17->Text="4";} } catch(Exception^ v){} } private: System::Void Studentlarni_yangilash_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) { safe_cast<Form^>(F1)->Show(); //this->Close(); //} } }; } Download 1.55 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling