Nebim V3 Z Raporuna İşlenmeyen Fişleri İşleyen Windows Form App

Categories C#, Nebim-V3Posted on

Form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Z_Import
{
    public partial class Form1 : Form
    {
        SqlConnection baglanti = new SqlConnection("Data Source=ServerAdresi; Initial Catalog = Veritabani; User Id = kullaniciadi; password=sifre;");

        public Form1()
        {
            InitializeComponent();
        }

        public static string gonderilecekveri;
        public static string gonderilecekveri2;
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            baglanti.Open();
            SqlCommand kmt = new SqlCommand("Select InvoiceHeaderID,CreatedUsername from AllInvoices where InvoiceNumber= ('" + textBox1.Text + "')", baglanti);
            SqlDataReader dr = kmt.ExecuteReader();
            if (dr.Read())
            {
                label2.Text = dr["InvoiceHeaderID"].ToString();
                label3.Text = dr["CreatedUserName"].ToString();

                gonderilecekveri = label2.Text;
                gonderilecekveri2 = label3.Text;


                Form2 yeni = new Form2();
                yeni.Show();
                this.Hide();

            }
            baglanti.Close();


        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

Form2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Z_Import
{
    public partial class Form2 : Form
    {
        SqlConnection baglanti2 = new SqlConnection("Data Source=ServerAdresi; Initial Catalog = Veritabani; User Id = kullaniciadi; password=sifre;");

        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            textBox1.Text = Form1.gonderilecekveri;
            textBox6.Text = Form1.gonderilecekveri2;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            baglanti2.Open();
            SqlCommand kmt2 = new SqlCommand("Insert INTO tpCashRegisterInfo (InvoiceHeaderID, CashRegisterSerialNumber, zNo, DocumentNumber, DocumentDate, CreatedUsername, EJNumber) Values  ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','1')", baglanti2);
            SqlDataReader dr2 = kmt2.ExecuteReader();
            baglanti2.Close();
            MessageBox.Show("İşlem Başarıyla Gerçekleşti");
           
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1 yeni = new Form1();
            yeni.Show();
            this.Hide();
        }
    }
}

Data Source=ServerAdresi;
Initial Catalog = Veritabani;
User Id = kullaniciadi; password=sifre

Bu kısmı kendinize göre düzenleyip exenizi derleyebilirsiniz.

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.