Exemple #1
0
        public async void button1_Click(object sender, EventArgs e)
        {
            info = dataGridView1.DataSource = await ApıDal <Employess> .GetInfo("employess");

            which = "employess";
            islem = " Listeleme";
            sonuc = JsonConvert.SerializeObject(info);
            logInfo.AddLog(islem, sonuc, "basarili", Form1.which); //response sonucuna göre basarili olma durumu değiştirilebilir.
            kolonAdet = dataGridView1.ColumnCount;
        }
Exemple #2
0
        private async void button2_Click(object sender, EventArgs e)
        {
            HttpClient client  = new HttpClient();
            LogInfo    logInfo = new LogInfo();
            string     islem   = "Kayıt Güncelleme";
            TextBox    tb      = ((TextBox)this.Controls["UpdtextBox0"]);
            TextBox    tb1     = ((TextBox)this.Controls["UpdtextBox1"]);
            TextBox    tb2     = ((TextBox)this.Controls["UpdtextBox2"]);
            TextBox    tb3     = ((TextBox)this.Controls["UpdtextBox3"]);
            TextBox    tb4     = ((TextBox)this.Controls["UpdtextBox4"]);
            TextBox    tb5     = ((TextBox)this.Controls["UpdtextBox5"]);
            TextBox    tb6     = ((TextBox)this.Controls["UpdtextBox6"]);
            TextBox    tb7     = ((TextBox)this.Controls["UpdtextBox7"]);
            TextBox    tb8     = ((TextBox)this.Controls["UpdtextBox8"]);
            TextBox    tb9     = ((TextBox)this.Controls["UpdtextBox9"]);
            TextBox    tb10    = ((TextBox)this.Controls["UpdtextBox10"]);
            TextBox    tb11    = ((TextBox)this.Controls["UpdtextBox11"]);
            TextBox    tb12    = ((TextBox)this.Controls["UpdtextBox12"]);
            TextBox    tb13    = ((TextBox)this.Controls["UpdtextBox13"]);
            TextBox    tb14    = ((TextBox)this.Controls["UpdtextBox14"]);

            switch (Form1.which)
            {
            case "categories":
                Categories cat = new Categories();
                cat.name        = tb1.Text;
                cat.description = tb2.Text;
                var convertedInf  = JsonConvert.SerializeObject(cat);
                var stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Categories> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "orders":
                Orders or = new Orders();
                WebAPI.ApıDal <Orders> .PostMethod(or, "orders");

                or.customerId   = tb1.Text;
                or.orderDate    = tb2.Text;
                or.requiredDate = tb3.Text;
                or.shippedDate  = tb4.Text;
                or.freight      = Convert.ToDouble(tb5.Text);
                or.shipName     = tb6.Text;
                convertedInf    = JsonConvert.SerializeObject(or);
                stringContent   = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Orders> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "employess":
                Employess emp = new Employess();
                emp.firstName       = tb1.Text;
                emp.lastName        = tb2.Text;
                emp.title           = tb3.Text;
                emp.titleOfCourtesy = tb4.Text;
                emp.birthDate       = tb5.Text;
                emp.hireDate        = tb6.Text;
                emp.notes           = tb8.Text;
                emp.reportsTo       = tb9.Text;
                convertedInf        = JsonConvert.SerializeObject(emp);
                stringContent       = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Employess> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "products":
                Products prod = new Products();
                prod.name            = tb1.Text;
                prod.quantityPerUnit = tb2.Text;
                prod.unitPrice       = Convert.ToInt32(tb3.Text);
                prod.unitsInStock    = Convert.ToInt32(tb4.Text);
                prod.unitsOnOrder    = Convert.ToInt32(tb5.Text);
                prod.reorderLevel    = Convert.ToInt32(tb6.Text);
                convertedInf         = JsonConvert.SerializeObject(prod);
                stringContent        = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Products> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "customers":
                Customers cust = new Customers();
                cust.companyName  = tb1.Text;
                cust.contactName  = tb2.Text;
                cust.contactTitle = tb3.Text;
                convertedInf      = JsonConvert.SerializeObject(cust);
                stringContent     = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Customers> .PatchAsync(client, stringContent, Form1.which, custid);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "suppliers":
                Suppliers supp = new Suppliers();
                supp.companyName  = tb1.Text;
                supp.contactName  = tb2.Text;
                supp.contactTitle = tb3.Text;
                convertedInf      = JsonConvert.SerializeObject(supp);
                stringContent     = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Suppliers> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi!");
                break;

            case "shippers":
                Shippers shipp = new Shippers();
                shipp.companyName = tb1.Text;
                shipp.phone       = tb2.Text;
                convertedInf      = JsonConvert.SerializeObject(shipp);
                stringContent     = new StringContent(convertedInf, Encoding.UTF8, "application/json");
                WebAPI.ApıDal <Shippers> .PatchAsync(client, stringContent, Form1.which, id);

                logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which);
                MessageBox.Show("Kayıt Başarıyla Güncellendi");
                break;

            default:
                break;
            }
        }