منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : إضافة عدة فواتير في آن واحد
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
السلام عليكم كيف حال الجميع ؟
لقد اتعبتني الفكرة لكن اريد تنفيذها او اي طريقة تروها مناسبة دلوني عليها
الفكرة هي كالأتي
عندي مجوعة من تكست بوكس و داتا قريدفيو اردت ان اضيف كل مرة داتا قريد جديدة في نفس الفورم و يتم ملأها من طرف التكست بوكس لكن بمعلومات مختلفة
قمت بإضافة التاب كونترول و كل مرة يتم فتح صفحة جديدة لكن كيف يمكن إستنساخ الداتا قريد في صفحة و جديدة و كيف يمكن اخلي التكست يضيف في الدتاقريد الجديدة و كيف تتم مثلا عملية الحفظ في قاعدة البيانات حسب الصفحة المفتوحة
وعليكم السلام...
هتنشئ جملة الاتصال عادي وكل داتا هيتم التعامل معها علي حسب الجدول ويجب الا تتشابه المدخلات مثل
Dim ds as New Dataset
فلا تكررها لكيلا يؤثر علي جدول أخر.
المشكلة ليست في إنشاء جملة الإتصال اخي اسامة
هو كيف تتم عملية الإضافة من التكست بوكس الى الداتا قريد الموجودة في الصفحة المفتوحة في تاب كونترول
و كيف يتم معرفة الداتا قريد لنحفظ بياناتها الى الداتابيز
انت عايز تحفظ في الداتا ثم تصدرها لجدول القاعدة.
لم افهم قصدك
PHP كود :
       private void button1_Click(object senderEventArgs e)
 
       {
 
           dataGridView1.Rows.Add(textBox1.TexttextBox2.TexttextBox3.Text);
 
       
السلام عليكم
لم تفهموا قصدي يا جماعة الخير
عندي مجموعة من التكست بوكس و عندي داتاقريد مجهزة في التاب كونترول
المطلوب هو عند الضغط على زر إضافة يتم فتح صفحة جديدة في التاب كونترول و يتم وضع فيها نفس الداتاقريد
المطلوب الثاني : هو عند نقل البيانات من التكست الى الداتاقريد يجب ان تنقل في الداتاقريد الموجودة في صفحة التاب كونترول المفتوحة (الحالية)
المطلوب الثالث : عند عملية الحفظ المعلومات يجب ان تحفظ المعلومات الموجودة في الداتاقريد الموجودة في صفحة التاب كونترول المفتوحة
PHP كود :
       private void button1_Click(object senderEventArgs e)
 
       {
 
           if (tabControl1.TabPages.Count == 1)
 
           {
 
               dataGridView1.Rows.Add(textBox1.TexttextBox2.TexttextBox3.Text);
 
               tabControl1.TabPages.Add("tabPage" Convert.ToInt32(tabControl1.TabPages.Count 1));
 
               DataGridView dgv = new DataGridView();
 
               //dgv = dataGridView1;
 
               for (int i 0dataGridView1.Columns.Counti++)
 
               {
 
                   dgv.Columns.Add(dataGridView1.Columns[i].NamedataGridView1.Columns[i].HeaderText);
 
               }
 
               dgv.Rows.Add(textBox1.TexttextBox2.TexttextBox3.Text);
 
               dgv.Name "dgv";
 
               dgv.Dock DockStyle.Fill;
 
               tabControl1.TabPages[tabControl1.TabPages.Count 1].Controls.Add(dgv);
 
           }
 
           else
            
{
 
               dataGridView1.Rows.Add(textBox1.TexttextBox2.TexttextBox3.Text);
 
               DataGridView dgv tabControl1.TabPages[tabControl1.TabPages.Count 1].Controls["dgv"] as DataGridView;
 
               dgv.Rows.Add(textBox1.TexttextBox2.TexttextBox3.Text);
 
           }
 
       
ينقل الى قسم اسئلة السي شارب .
استاذ الله يفتح عليك
إعادة كتابة الكود بلغة البيسيك لاني لم انتبه ان الملف الذي ارفقته هو مشروع بلغة الشارب
هذا الكود بناء على المرفق بلغة #C وفي قسم اسئلة C#.NET

اولا ملف التصميم Form1.Designer.cs
PHP كود :
namespace WindowsFormsApplication1
{
 
   partial class Form1
    
{
 
       /// <summary>
 
       /// Required designer variable.
 
       /// </summary>
 
       private System.ComponentModel.IContainer components null;

 
       /// <summary>
 
       /// Clean up any resources being used.
 
       /// </summary>
 
       /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 
       protected override void Dispose(bool disposing)
 
       {
 
           if (disposing && (components != null))
 
           {
 
               components.Dispose();
 
           }
 
           base.Dispose(disposing);
 
       }

 
       #region Windows Form Designer generated code

 
       /// <summary>
 
       /// Required method for Designer support - do not modify
 
       /// the contents of this method with the code editor.
 
       /// </summary>
 
       private void InitializeComponent()
 
       {
 
           this.panel1 = new System.Windows.Forms.Panel();
 
           this.comboBox_CustomName = new System.Windows.Forms.ComboBox();
 
           this.textBox_QTY = new System.Windows.Forms.TextBox();
 
           this.textBox_Price = new System.Windows.Forms.TextBox();
 
           this.textBox_Product = new System.Windows.Forms.TextBox();
 
           this.label3 = new System.Windows.Forms.Label();
 
           this.label5 = new System.Windows.Forms.Label();
 
           this.label2 = new System.Windows.Forms.Label();
 
           this.label1 = new System.Windows.Forms.Label();
 
           this.button_AddToDGV = new System.Windows.Forms.Button();
 
           this.button_Save = new System.Windows.Forms.Button();
 
           this.button3 = new System.Windows.Forms.Button();
 
           this.tabControl1 = new System.Windows.Forms.TabControl();
 
           this.panel1.SuspendLayout();
 
           this.SuspendLayout();
 
           // 
 
           // panel1
 
           // 
 
           this.panel1.BorderStyle System.Windows.Forms.BorderStyle.FixedSingle;
 
           this.panel1.Controls.Add(this.comboBox_CustomName);
 
           this.panel1.Controls.Add(this.textBox_QTY);
 
           this.panel1.Controls.Add(this.textBox_Price);
 
           this.panel1.Controls.Add(this.textBox_Product);
 
           this.panel1.Controls.Add(this.label3);
 
           this.panel1.Controls.Add(this.label5);
 
           this.panel1.Controls.Add(this.label2);
 
           this.panel1.Controls.Add(this.label1);
 
           this.panel1.Controls.Add(this.button_AddToDGV);
 
           this.panel1.Location = new System.Drawing.Point(1212);
 
           this.panel1.Name "panel1";
 
           this.panel1.Size = new System.Drawing.Size(264157);
 
           this.panel1.TabIndex 0;
 
           // 
 
           // comboBox_CustomName
 
           // 
 
           this.comboBox_CustomName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Left
 
           System.Windows.Forms.AnchorStyles.Right)));
 
           this.comboBox_CustomName.FormattingEnabled true;
 
           this.comboBox_CustomName.Location = new System.Drawing.Point(610);
 
           this.comboBox_CustomName.Name "comboBox_CustomName";
 
           this.comboBox_CustomName.Size = new System.Drawing.Size(17021);
 
           this.comboBox_CustomName.TabIndex 1;
 
           this.comboBox_CustomName.SelectedIndexChanged += new System.EventHandler(this.comboBox_CustomName_SelectedIndexChanged);
 
           // 
 
           // textBox_QTY
 
           // 
 
           this.textBox_QTY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.textBox_QTY.Location = new System.Drawing.Point(9689);
 
           this.textBox_QTY.Name "textBox_QTY";
 
           this.textBox_QTY.Size = new System.Drawing.Size(10020);
 
           this.textBox_QTY.TabIndex 7;
 
           // 
 
           // textBox_Price
 
           // 
 
           this.textBox_Price.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.textBox_Price.Location = new System.Drawing.Point(9663);
 
           this.textBox_Price.Name "textBox_Price";
 
           this.textBox_Price.Size = new System.Drawing.Size(10020);
 
           this.textBox_Price.TabIndex 5;
 
           // 
 
           // textBox_Product
 
           // 
 
           this.textBox_Product.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Left
 
           System.Windows.Forms.AnchorStyles.Right)));
 
           this.textBox_Product.Location = new System.Drawing.Point(637);
 
           this.textBox_Product.Name "textBox_Product";
 
           this.textBox_Product.Size = new System.Drawing.Size(19020);
 
           this.textBox_Product.TabIndex 3;
 
           // 
 
           // label3
 
           // 
 
           this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.label3.AutoSize true;
 
           this.label3.Font = new System.Drawing.Font("Times New Roman"12FSystem.Drawing.FontStyle.Bold);
 
           this.label3.Location = new System.Drawing.Point(20988);
 
           this.label3.Name "label3";
 
           this.label3.Size = new System.Drawing.Size(5019);
 
           this.label3.TabIndex 6;
 
           this.label3.Text "الكمية :";
 
           // 
 
           // label5
 
           // 
 
           this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.label5.AutoSize true;
 
           this.label5.Font = new System.Drawing.Font("Times New Roman"12FSystem.Drawing.FontStyle.Bold);
 
           this.label5.Location = new System.Drawing.Point(1829);
 
           this.label5.Name "label5";
 
           this.label5.Size = new System.Drawing.Size(7719);
 
           this.label5.TabIndex 0;
 
           this.label5.Text "إسم الزبون :";
 
           // 
 
           // label2
 
           // 
 
           this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.label2.AutoSize true;
 
           this.label2.Font = new System.Drawing.Font("Times New Roman"12FSystem.Drawing.FontStyle.Bold);
 
           this.label2.Location = new System.Drawing.Point(21362);
 
           this.label2.Name "label2";
 
           this.label2.Size = new System.Drawing.Size(4619);
 
           this.label2.TabIndex 4;
 
           this.label2.Text "الثمن :";
 
           // 
 
           // label1
 
           // 
 
           this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.label1.AutoSize true;
 
           this.label1.Font = new System.Drawing.Font("Times New Roman"12FSystem.Drawing.FontStyle.Bold);
 
           this.label1.Location = new System.Drawing.Point(20236);
 
           this.label1.Name "label1";
 
           this.label1.Size = new System.Drawing.Size(5719);
 
           this.label1.TabIndex 2;
 
           this.label1.Text "المنتوج :";
 
           // 
 
           // button_AddToDGV
 
           // 
 
           this.button_AddToDGV.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom System.Windows.Forms.AnchorStyles.Left)));
 
           this.button_AddToDGV.Location = new System.Drawing.Point(3123);
 
           this.button_AddToDGV.Name "button_AddToDGV";
 
           this.button_AddToDGV.Size = new System.Drawing.Size(17329);
 
           this.button_AddToDGV.TabIndex 8;
 
           this.button_AddToDGV.Text "إضافة الى الجدول";
 
           this.button_AddToDGV.UseVisualStyleBackColor true;
 
           this.button_AddToDGV.Click += new System.EventHandler(this.button_AddToDGV_Click);
 
           // 
 
           // button_Save
 
           // 
 
           this.button_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Right)));
 
           this.button_Save.Location = new System.Drawing.Point(542175);
 
           this.button_Save.Name "button_Save";
 
           this.button_Save.Size = new System.Drawing.Size(11023);
 
           this.button_Save.TabIndex 2;
 
           this.button_Save.Text "حفظ";
 
           this.button_Save.UseVisualStyleBackColor true;
 
           this.button_Save.Click += new System.EventHandler(this.button_Save_Click);
 
           // 
 
           // button3
 
           // 
 
           this.button3.Enabled false;
 
           this.button3.Location = new System.Drawing.Point(282175);
 
           this.button3.Name "button3";
 
           this.button3.Size = new System.Drawing.Size(15033);
 
           this.button3.TabIndex 3;
 
           this.button3.Text "إضافة عملية بيع جديدة";
 
           this.button3.UseVisualStyleBackColor true;
 
           // 
 
           // tabControl1
 
           // 
 
           this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Left
 
           System.Windows.Forms.AnchorStyles.Right)));
 
           this.tabControl1.Location = new System.Drawing.Point(28212);
 
           this.tabControl1.Name "tabControl1";
 
           this.tabControl1.RightToLeftLayout true;
 
           this.tabControl1.SelectedIndex 0;
 
           this.tabControl1.Size = new System.Drawing.Size(370157);
 
           this.tabControl1.TabIndex 1;
 
           // 
 
           // Form1
 
           // 
 
           this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
 
           this.AutoScaleMode System.Windows.Forms.AutoScaleMode.Font;
 
           this.ClientSize = new System.Drawing.Size(664218);
 
           this.Controls.Add(this.tabControl1);
 
           this.Controls.Add(this.button3);
 
           this.Controls.Add(this.button_Save);
 
           this.Controls.Add(this.panel1);
 
           this.Name "Form1";
 
           this.RightToLeft System.Windows.Forms.RightToLeft.Yes;
 
           this.RightToLeftLayout true;
 
           this.Text "Form1";
 
           this.Load += new System.EventHandler(this.Form1_Load);
 
           this.panel1.ResumeLayout(false);
 
           this.panel1.PerformLayout();
 
           this.ResumeLayout(false);

 
       }

 
       #endregion

 
       private System.Windows.Forms.Panel panel1;
 
       private System.Windows.Forms.TextBox textBox_QTY;
 
       private System.Windows.Forms.TextBox textBox_Price;
 
       private System.Windows.Forms.TextBox textBox_Product;
 
       private System.Windows.Forms.Label label3;
 
       private System.Windows.Forms.Label label2;
 
       private System.Windows.Forms.Label label1;
 
       private System.Windows.Forms.Button button_AddToDGV;
 
       private System.Windows.Forms.Button button_Save;
 
       private System.Windows.Forms.Button button3;
 
       private System.Windows.Forms.TabControl tabControl1;
 
       private System.Windows.Forms.ComboBox comboBox_CustomName;
 
       private System.Windows.Forms.Label label5;
 
   }


ثانيا ملف الكود Form1.cs
PHP كود :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 
WindowsFormsApplication1
{
 
   public partial class Form1 Form
    
{

 
       public Form1()
 
       {
 
           InitializeComponent();
 
           try {
 
               InputLanguage.CurrentInputLanguage =
 
                   InputLanguage.InstalledInputLanguages.Cast<InputLanguage>()
 
                   .FirstOrDefault(lang => lang.Culture.EnglishName.ToLower().StartsWith("ar"));
 
           } catch (Exception ex) { }
 
       }




 
       private void comboBox_CustomName_SelectedIndexChanged(object senderEventArgs e) {
 
           if (comboBox_CustomName.SelectedIndex != -1) {
 
               String customerName comboBox_CustomName.Text.Trim();

 
               TabPage tb tabControl1.TabPages[customerName];
 
               tabControl1.SelectedTab tb;
 
           }
 
       }




 
       private void button_AddToDGV_Click(object senderEventArgs e) {

 
           String customerName comboBox_CustomName.Text.Trim();

 
           comboBox_CustomName.SelectedIndex comboBox_CustomName.FindStringExact(customerName0);
 
           if (comboBox_CustomName.SelectedIndex == -1) {
 
               if (NewCustomer() == false) return;
 
               comboBox_CustomName.Items.Add(customerName);
 
           }


 
           TabPage tb tabControl1.TabPages[customerName];
 
           tabControl1.SelectedTab tb;


 
           String product textBox_Product.Text.Trim();
 
           if (product.Equals("")) {
 
               MessageBox.Show("أكتب اسم المنتوج");
 
               return;
 
           }


 
           double price;
 
           int qty;
 
           try {
 
               price Convert.ToDouble(textBox_Price.Text);
 
               qty Convert.ToInt32(textBox_QTY.Text);
 
           } catch (Exception ex) {
 
               MessageBox.Show("تأكد من البيانات");
 
               return;
 
           }


 
           DataGridView dgv = (DataGridView)tb.Controls[0];
 
           dgv.Rows.Add(product.ToString(), price.ToString(), qty.ToString());
 
           dgv.FirstDisplayedScrollingRowIndex dgv.Rows.Count 1;
 
           dgv.Rows[dgv.Rows.Count 1].Cells[0].Selected true;

 
           textBox_Product.Clear();
 
           textBox_Price.Clear();
 
           textBox_QTY.Clear();


 
           textBox_Product.Focus();
 
       }




 
       private void button_Save_Click(object senderEventArgs e) {
 
           if (tabControl1.SelectedTab == null) return;

 
           TabPage tb tabControl1.SelectedTab;
 
           DataGridView dgv = (DataGridView)tb.Controls[0];

 
           String customerName tb.Text;

 
           // dgv = الداتاجريد
 
           StringBuilder builder = new StringBuilder();
 
           builder.AppendLine(customerName);

 
           foreach (DataGridViewRow row in dgv.Rows)
 
               builder.AppendLine(
 
                   row.Cells[0].Value.ToString()
 
                   " [" row.Cells[2].Value.ToString() + "] = "
 
                   row.Cells[1].Value.ToString());

 
           MessageBox.Show(
 
               builder.ToString(), tb.Text,
 
               MessageBoxButtons.OKMessageBoxIcon.InformationMessageBoxDefaultButton.Button1,
 
               MessageBoxOptions.RightAlign);

 
       }




 
       private bool NewCustomer() {

 
           String customerName comboBox_CustomName.Text.Trim();
 
           if (customerName.Equals(String.Empty)) {
 
               MessageBox.Show("أكتب اسم الزبزن");
 
               return false;
 
           }

 
           TabPage tb = new TabPage() { Name customerNameText customerName };
 
           tb.Text customerName;
 
           tb.Controls.Add(NewDataGridView());
 
           this.tabControl1.TabPages.Add(tb);
 
           this.tabControl1.SelectedTab tb;
 
           return true;
 
       }




 
       private DataGridView NewDataGridView() {

 
           DataGridView dataGridView = new DataGridView() {
 
               Dock DockStyle.Fill,
 
               ReadOnly true,
 
               AllowUserToAddRows false,
 
               MultiSelect false,
 
               SelectionMode DataGridViewSelectionMode.FullRowSelect
            
};

 
           DataGridViewTextBoxColumn product = new DataGridViewTextBoxColumn() { Name "product"HeaderText "المنتوج" };
 
           DataGridViewTextBoxColumn price = new DataGridViewTextBoxColumn() { Name "price"HeaderText "الثمن" };
 
           DataGridViewTextBoxColumn qty = new DataGridViewTextBoxColumn() { Name "qty"HeaderText "الكمية" };
 
           dataGridView.Columns.AddRange(new DataGridViewColumn[] { productpriceqty });

 
           return dataGridView;
 
       }

 
   }





وهذا الكود بناء على تغيير كلامك وطلبك للكود بلغة البيسيك بالرغم من كونه في قسم اسئلة C#.NET

اولا ملف التصميم Form1.Designer.vb
PHP كود :
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial 
Class Form1
    Inherits System
.Windows.Forms.Form

    
'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    '
Required by the Windows Form Designer
    Private components 
As System.ComponentModel.IContainer

    
'NOTE: The following procedure is required by the Windows Form Designer
    '
It can be modified using the Windows Form Designer 
    
'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.button3 = New System.Windows.Forms.Button()
        Me.comboBox_CustomName = New System.Windows.Forms.ComboBox()
        Me.button_Save = New System.Windows.Forms.Button()
        Me.textBox_QTY = New System.Windows.Forms.TextBox()
        Me.textBox_Price = New System.Windows.Forms.TextBox()
        Me.textBox_Product = New System.Windows.Forms.TextBox()
        Me.label3 = New System.Windows.Forms.Label()
        Me.panel1 = New System.Windows.Forms.Panel()
        Me.label5 = New System.Windows.Forms.Label()
        Me.label2 = New System.Windows.Forms.Label()
        Me.label1 = New System.Windows.Forms.Label()
        Me.button_AddToDGV = New System.Windows.Forms.Button()
        Me.tabControl1 = New System.Windows.Forms.TabControl()
        Me.panel1.SuspendLayout()
        Me.SuspendLayout()
        '
 
       'button3
        '
 
       Me.button3.Enabled False
        Me
.button3.Location = New System.Drawing.Point(282175)
 
       Me.button3.Name "button3"
 
       Me.button3.Size = New System.Drawing.Size(15033)
 
       Me.button3.TabIndex 7
        Me
.button3.Text "إضافة عملية بيع جديدة"
 
       Me.button3.UseVisualStyleBackColor True
        
'
        '
comboBox_CustomName
        
'
        Me.comboBox_CustomName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.comboBox_CustomName.FormattingEnabled = True
        Me.comboBox_CustomName.Location = New System.Drawing.Point(6, 10)
        Me.comboBox_CustomName.Name = "comboBox_CustomName"
        Me.comboBox_CustomName.Size = New System.Drawing.Size(170, 21)
        Me.comboBox_CustomName.TabIndex = 1
        '
 
       'button_Save
        '
 
       Me.button_Save.Anchor CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.button_Save.Location = New System.Drawing.Point(542175)
 
       Me.button_Save.Name "button_Save"
 
       Me.button_Save.Size = New System.Drawing.Size(11023)
 
       Me.button_Save.TabIndex 6
        Me
.button_Save.Text "حفظ"
 
       Me.button_Save.UseVisualStyleBackColor True
        
'
        '
textBox_QTY
        
'
        Me.textBox_QTY.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.textBox_QTY.Location = New System.Drawing.Point(96, 89)
        Me.textBox_QTY.Name = "textBox_QTY"
        Me.textBox_QTY.Size = New System.Drawing.Size(100, 20)
        Me.textBox_QTY.TabIndex = 7
        '
 
       'textBox_Price
        '
 
       Me.textBox_Price.Anchor CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.textBox_Price.Location = New System.Drawing.Point(9663)
 
       Me.textBox_Price.Name "textBox_Price"
 
       Me.textBox_Price.Size = New System.Drawing.Size(10020)
 
       Me.textBox_Price.TabIndex 5
        
'
        '
textBox_Product
        
'
        Me.textBox_Product.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.textBox_Product.Location = New System.Drawing.Point(6, 37)
        Me.textBox_Product.Name = "textBox_Product"
        Me.textBox_Product.Size = New System.Drawing.Size(190, 20)
        Me.textBox_Product.TabIndex = 3
        '
 
       'label3
        '
 
       Me.label3.Anchor CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.label3.AutoSize True
        Me
.label3.Font = New System.Drawing.Font("Times New Roman"12.0!, System.Drawing.FontStyle.Bold)
 
       Me.label3.Location = New System.Drawing.Point(20988)
 
       Me.label3.Name "label3"
 
       Me.label3.Size = New System.Drawing.Size(5019)
 
       Me.label3.TabIndex 6
        Me
.label3.Text "الكمية :"
 
       '
        '
panel1
        
'
        Me.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.panel1.Controls.Add(Me.comboBox_CustomName)
        Me.panel1.Controls.Add(Me.textBox_QTY)
        Me.panel1.Controls.Add(Me.textBox_Price)
        Me.panel1.Controls.Add(Me.textBox_Product)
        Me.panel1.Controls.Add(Me.label3)
        Me.panel1.Controls.Add(Me.label5)
        Me.panel1.Controls.Add(Me.label2)
        Me.panel1.Controls.Add(Me.label1)
        Me.panel1.Controls.Add(Me.button_AddToDGV)
        Me.panel1.Location = New System.Drawing.Point(12, 12)
        Me.panel1.Name = "panel1"
        Me.panel1.Size = New System.Drawing.Size(264, 157)
        Me.panel1.TabIndex = 4
        '
 
       'label5
        '
 
       Me.label5.Anchor CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.label5.AutoSize True
        Me
.label5.Font = New System.Drawing.Font("Times New Roman"12.0!, System.Drawing.FontStyle.Bold)
 
       Me.label5.Location = New System.Drawing.Point(1829)
 
       Me.label5.Name "label5"
 
       Me.label5.Size = New System.Drawing.Size(7719)
 
       Me.label5.TabIndex 0
        Me
.label5.Text "إسم الزبون :"
 
       '
        '
label2
        
'
        Me.label2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.label2.AutoSize = True
        Me.label2.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold)
        Me.label2.Location = New System.Drawing.Point(213, 62)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(46, 19)
        Me.label2.TabIndex = 4
        Me.label2.Text = "الثمن :"
        '
 
       'label1
        '
 
       Me.label1.Anchor CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.label1.AutoSize True
        Me
.label1.Font = New System.Drawing.Font("Times New Roman"12.0!, System.Drawing.FontStyle.Bold)
 
       Me.label1.Location = New System.Drawing.Point(20236)
 
       Me.label1.Name "label1"
 
       Me.label1.Size = New System.Drawing.Size(5719)
 
       Me.label1.TabIndex 2
        Me
.label1.Text "المنتوج :"
 
       '
        '
button_AddToDGV
        
'
        Me.button_AddToDGV.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.button_AddToDGV.Location = New System.Drawing.Point(3, 123)
        Me.button_AddToDGV.Name = "button_AddToDGV"
        Me.button_AddToDGV.Size = New System.Drawing.Size(173, 29)
        Me.button_AddToDGV.TabIndex = 8
        Me.button_AddToDGV.Text = "إضافة الى الجدول"
        Me.button_AddToDGV.UseVisualStyleBackColor = True
        '
 
       'tabControl1
        '
 
       Me.tabControl1.Anchor CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left_
            Or System
.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
 
       Me.tabControl1.Location = New System.Drawing.Point(28212)
 
       Me.tabControl1.Name "tabControl1"
 
       Me.tabControl1.RightToLeftLayout True
        Me
.tabControl1.SelectedIndex 0
        Me
.tabControl1.Size = New System.Drawing.Size(370157)
 
       Me.tabControl1.TabIndex 5
        
'
        '
Form1
        
'
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(664, 218)
        Me.Controls.Add(Me.button3)
        Me.Controls.Add(Me.button_Save)
        Me.Controls.Add(Me.panel1)
        Me.Controls.Add(Me.tabControl1)
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.RightToLeftLayout = True
        Me.Text = "Form1"
        Me.panel1.ResumeLayout(False)
        Me.panel1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
    Private WithEvents button3 As System.Windows.Forms.Button
    Private WithEvents comboBox_CustomName As System.Windows.Forms.ComboBox
    Private WithEvents button_Save As System.Windows.Forms.Button
    Private WithEvents textBox_QTY As System.Windows.Forms.TextBox
    Private WithEvents textBox_Price As System.Windows.Forms.TextBox
    Private WithEvents textBox_Product As System.Windows.Forms.TextBox
    Private WithEvents label3 As System.Windows.Forms.Label
    Private WithEvents panel1 As System.Windows.Forms.Panel
    Private WithEvents label5 As System.Windows.Forms.Label
    Private WithEvents label2 As System.Windows.Forms.Label
    Private WithEvents label1 As System.Windows.Forms.Label
    Private WithEvents button_AddToDGV As System.Windows.Forms.Button
    Private WithEvents tabControl1 As System.Windows.Forms.TabControl

End Class 

ثانيا ملف الكود Form1.vb
PHP كود :
Imports System.Text

Public Class Form1


    Private Sub Form1_Load
(sender As ObjectAs EventArgsHandles MyBase.Load
        Try
            InputLanguage
.CurrentInputLanguage InputLanguage.InstalledInputLanguages.Cast(Of InputLanguage)().Where(Function(langlang.Culture.EnglishName.ToLower.StartsWith("ar")).FirstOrDefault
        Catch ex 
As Exception
        End 
Try
 
   End Sub


    Private Sub comboBox_CustomName_SelectedIndexChanged
(sender As ObjectAs EventArgsHandles comboBox_CustomName.SelectedIndexChanged
        If comboBox_CustomName
.SelectedIndex <> -1 Then
            Dim customerName 
As String comboBox_CustomName.Text.Trim()
 
           Dim tb As TabPage tabControl1.TabPages(customerName)
 
           tabControl1.SelectedTab tb
        End 
If
 
   End Sub


    Private Sub button_AddToDGV_Click
(sender As ObjectAs EventArgsHandles button_AddToDGV.Click

        Dim customerName 
As String comboBox_CustomName.Text.Trim

        comboBox_CustomName
.SelectedIndex comboBox_CustomName.FindStringExact(customerName0)
 
       If (comboBox_CustomName.SelectedIndex = -1Then
            If NewCustomer
() = False Then Return
 
           comboBox_CustomName.Items.Add(customerName)
 
       End If


 
       Dim tb As TabPage tabControl1.TabPages(customerName)
 
       tabControl1.SelectedTab tb


        Dim product 
As String textBox_Product.Text.Trim
        If 
(product.Equals("")) Then
            MessageBox
.Show("أكتب اسم المنتوج")
 
           Return
        End 
If


 
       Dim price As Double
        Dim qty 
As Integer
        Try
            price 
Convert.ToDouble(textBox_Price.Text)
 
           qty Convert.ToInt32(textBox_QTY.Text)

 
       Catch ex As Exception
            MessageBox
.Show("تأكد من البيانات")
 
           Return
        End 
Try



 
       Dim dgv As DataGridView TryCast(tbTabPage).Controls(0)
 
       dgv.Rows.Add(product.ToString(), price.ToString(), qty.ToString)
 
       dgv.FirstDisplayedScrollingRowIndex dgv.Rows.Count 1
        dgv
.Rows(dgv.Rows.Count 1).Cells(0).Selected True

        textBox_Product
.Clear()
 
       textBox_Price.Clear()
 
       textBox_QTY.Clear()


 
       textBox_Product.Focus()
 
   End Sub



    Private Sub button_Save_Click
(sender As ObjectAs EventArgsHandles button_Save.Click
        If tabControl1
.SelectedTab Is Nothing Then Return

 
       Dim tb As TabPage tabControl1.SelectedTab
        Dim dgv 
As DataGridView TryCast(tbTabPage).Controls(0)

 
       Dim customerName As String tb.Text

        
' dgv = الداتاجريد
        Dim builder As StringBuilder = New StringBuilder
        builder.AppendLine(customerName)

        For Each row As DataGridViewRow In dgv.Rows
            builder.AppendLine( _
                row.Cells(0).Value.ToString & _
                 " [" + row.Cells(2).Value.ToString() + "] = " & _
                 row.Cells(1).Value.ToString)
        Next

        MessageBox.Show(
            builder.ToString(), tb.Text,
            MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1,
            MessageBoxOptions.RightAlign)

    End Sub



    Private Function NewCustomer() As Boolean

        Dim customerName As String = comboBox_CustomName.Text.Trim
        If customerName.Equals(String.Empty) Then
            MessageBox.Show("أكتب اسم الزبزن")
            Return False
        End If

        Dim tb As New TabPage() With {.Name = customerName, .Text = customerName}
        tb.Text = customerName
        tb.Controls.Add(NewDataGridView())
        Me.tabControl1.TabPages.Add(tb)
        Me.tabControl1.SelectedTab = tb
        Return True
    End Function




    Private Function NewDataGridView() As DataGridView

        Dim dataGridView As New DataGridView() With { _
                .Dock = DockStyle.Fill, _
                .ReadOnly = True, _
                .AllowUserToAddRows = False, _
                .MultiSelect = False, _
                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
            }

        Dim product As New DataGridViewTextBoxColumn() With {.Name = "product", .HeaderText = "المنتوج"}
        Dim price As New DataGridViewTextBoxColumn() With {.Name = "price", .HeaderText = "الثمن"}
        Dim qty As New DataGridViewTextBoxColumn() With {.Name = "qty", .HeaderText = "الكمية"}
        dataGridView.Columns.AddRange(New DataGridViewColumn() {product, price, qty})

        Return dataGridView
    End Function


End Class 
الصفحات : 1 2