Example #1
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (TEDARIKCI_KOD.Text != "" && TEDARIKCI_AD.Text != "")
            {
                WebService kntlService = new WebService();
                kntlService.SQLText = "SELECT TEDARIKCI_KODU FROM TBLTEDARIKCI WHERE TEDARIKCI_KODU = '" + TEDARIKCI_KOD.Text + "'";
                kntlService.Open();
                if (kntlService.DataCount() > 0)
                {
                    string image = "";
                    if (imageChanged && !Goto724Lib.isNoImage(TEDARIKCI_RESIM.Image))
                    {
                        image = Goto724Lib.ByteArrayToString(Goto724Lib.ImageToByteArray(TEDARIKCI_RESIM.Image));
                    }

                    string updStr = "UPDATE TBLTEDARIKCI SET TEDARIKCI_ADI = '" + TEDARIKCI_AD.Text + "'";

                    if (UST_NO.Text != "")
                    {
                        updStr += ", UST_NO = '" + UST_NO.Text + "'";
                    }
                    else
                    {
                        updStr += ", UST_NO = NULL";
                    }

                    if (CADDE_SOKAK.Text != "")
                    {
                        updStr += ", CADDE_SOKAK = '" + CADDE_SOKAK.Text + "'";
                    }
                    else
                    {
                        updStr += ", CADDE_SOKAK = NULL";
                    }

                    if (ULKE.Text != "")
                    {
                        updStr += ", ULKE = '" + ULKE.Text + "'";
                    }
                    else
                    {
                        updStr += ", ULKE = NULL";
                    }

                    if (BINA_NO.Text != "")
                    {
                        updStr += ", BINA_NO = '" + BINA_NO.Text + "'";
                    }
                    else
                    {
                        updStr += ", BINA_NO = NULL";
                    }

                    if (SEHIR.Text != "")
                    {
                        updStr += ", SEHIR = '" + SEHIR.Text + "'";
                    }
                    else
                    {
                        updStr += ", SEHIR = NULL";
                    }

                    if (POSTA_KODU.Text != "")
                    {
                        updStr += ", POSTA_KODU = '" + POSTA_KODU.Text + "'";
                    }
                    else
                    {
                        updStr += ", POSTA_KODU = NULL";
                    }

                    if (TEL_NO.Text != "")
                    {
                        updStr += ", TEL_NO = '" + TEL_NO.Text + "'";
                    }
                    else
                    {
                        updStr += ", TEL_NO = NULL";
                    }

                    if (CEP_TELNO.Text != "")
                    {
                        updStr += ", CEP_TEL = '" + CEP_TELNO.Text + "'";
                    }
                    else
                    {
                        updStr += ", CEP_TEL = NULL";
                    }

                    if (EPOSTA.Text != "")
                    {
                        updStr += ", E_POSTA = '" + EPOSTA.Text + "'";
                    }
                    else
                    {
                        updStr += ", E_POSTA = NULL";
                    }

                    if (WEBSITE.Text != "")
                    {
                        updStr += ", WEB_SITE = '" + WEBSITE.Text + "'";
                    }
                    else
                    {
                        updStr += ", WEB_SITE = NULL";
                    }

                    if (ACIKLAMA1.Text != "")
                    {
                        updStr += ", ACIKLAMA_1 = '" + ACIKLAMA1.Text + "'";
                    }
                    else
                    {
                        updStr += ", ACIKLAMA_1 = NULL";
                    }

                    if (ACIKLAMA2.Text != "")
                    {
                        updStr += ", ACIKLAMA_2 = '" + ACIKLAMA2.Text + "'";
                    }
                    else
                    {
                        updStr += ", ACIKLAMA_2 = NULL";
                    }

                    if (TEDARIKCI_KISA_AD.Text != "")
                    {
                        updStr += ", TEDARIKCI_KISA_AD = '" + TEDARIKCI_KISA_AD.Text + "'";
                    }
                    else
                    {
                        updStr += ", TEDARIKCI_KISA_AD = NULL";
                    }

                    if (FAX.Text != "")
                    {
                        updStr += ", FAX = '" + FAX.Text + "'";
                    }
                    else
                    {
                        updStr += ", FAX = NULL";
                    }

                    if (ACIL_TELNO.Text != "")
                    {
                        updStr += ", ACIL_TELNO = '" + ACIL_TELNO.Text + "'";
                    }
                    else
                    {
                        updStr += ", ACIL_TELNO = NULL";
                    }

                    if (TEL_NO2.Text != "")
                    {
                        updStr += ", TEL_NO2 = '" + TEL_NO2.Text + "'";
                    }
                    else
                    {
                        updStr += ", TEL_NO2 = NULL";
                    }

                    if (TEL_NO3.Text != "")
                    {
                        updStr += ", TEL_NO3 = '" + TEL_NO3.Text + "'";
                    }
                    else
                    {
                        updStr += ", TEL_NO3 = NULL";
                    }

                    if (PASIF_MI.SelectedIndex == -1 || PASIF_MI.SelectedIndex == 0)
                    {
                        updStr += ", PASIF_MI = 'H'";
                    }
                    else
                    {
                        updStr += ", PASIF_MI = 'E'";
                    }

                    if (image != "")
                    {
                        updStr += ", TEDARIKCI_RESIM = 0x" + image;
                    }

                    if (chbKATEGORI.SelectedIndex != -1)
                    {
                        updStr += ", KATEGORI= '" + SecilenKategori() + "'";
                    }
                    else
                    {
                        updStr += ", KATEGORI= NULL";
                    }

                    updStr += " WHERE TEDARIKCI_KODU = '" + TEDARIKCI_KOD.Text + "'";

                    WebService service = new WebService();
                    service.SQLText = updStr;
                    service.Open();
                    if (service.errorCode == "0")
                    {
                        GotoMessage.ShowMessage("Bilgi", "Kayıt Düzenleme Tamamlandı");
                        if (Goto724Lib.adminMi)
                        {
                            PanelClear();
                            RefreshGrid();
                        }
                    }
                    else
                    {
                        GotoMessage.ShowMessage("Hata", "Kayıt Aktarılırken Hatayla Karşılaşıldı.\nHata: " + service.description);
                    }
                }
                else
                {
                    WebService lisansService = new WebService();
                    lisansService.SQLText = "SELECT SON_NUMARA FROM TBLOTONUM WHERE NUMARA_KODU = '" + DateTime.Now.ToString("yyMM") + "_LISANS'";
                    lisansService.Open();
                    bool lisansUpKontrol = false;
                    int  sonNum          = 0;
                    if (lisansService.DataCount() > 0)
                    {
                        lisansUpKontrol      = true;
                        sonNum               = Convert.ToInt32(lisansService.GetString("SON_NUMARA"));
                        LISANS_NUMARASI.Text = Goto724Lib.CreateLisansNumarasi(sonNum);
                        LISANS_SIFRESI.Text  = Goto724Lib.CreateLisansSifresi();
                    }
                    else
                    {
                        LISANS_NUMARASI.Text = Goto724Lib.CreateLisansNumarasi(0);
                        LISANS_SIFRESI.Text  = Goto724Lib.CreateLisansSifresi();
                    }

                    string image = "";
                    if (imageChanged && !Goto724Lib.isNoImage(TEDARIKCI_RESIM.Image))
                    {
                        image = Goto724Lib.ByteArrayToString(Goto724Lib.ImageToByteArray(TEDARIKCI_RESIM.Image));
                    }

                    string insStr = "INSERT INTO TBLTEDARIKCI(TEDARIKCI_KODU, TEDARIKCI_ADI, UST_NO, CADDE_SOKAK, TEL_NO, CEP_TEL, E_POSTA, WEB_SITE, ACIKLAMA_1, ACIKLAMA_2, BINA_NO, SEHIR, POSTA_KODU, ULKE, TEDARIKCI_KISA_AD, FAX, ACIL_TELNO, TEL_NO2, TEL_NO3, PASIF_MI, LISANS_NUMARASI,  LISANS_SIFRESI, KATEGORI";
                    if (image != "")
                    {
                        insStr += ", TEDARIKCI_RESIM) ";
                    }
                    else
                    {
                        insStr += ")";
                    }
                    insStr += "VALUES ('" + TEDARIKCI_KOD.Text + "', '" + TEDARIKCI_AD.Text + "'";

                    if (UST_NO.Text != "")
                    {
                        insStr += ", '" + UST_NO.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (CADDE_SOKAK.Text != "")
                    {
                        insStr += ", '" + CADDE_SOKAK.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (TEL_NO.Text != "")
                    {
                        insStr += ", '" + TEL_NO.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (CEP_TELNO.Text != "")
                    {
                        insStr += ", '" + CEP_TELNO.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (EPOSTA.Text != "")
                    {
                        insStr += ", '" + EPOSTA.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (WEBSITE.Text != "")
                    {
                        insStr += ", '" + WEBSITE.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (ACIKLAMA1.Text != "")
                    {
                        insStr += ", '" + ACIKLAMA1.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (ACIKLAMA2.Text != "")
                    {
                        insStr += ", '" + ACIKLAMA2.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (BINA_NO.Text != "")
                    {
                        insStr += ", '" + BINA_NO.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (SEHIR.Text != "")
                    {
                        insStr += ", '" + SEHIR.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (POSTA_KODU.Text != "")
                    {
                        insStr += ", '" + POSTA_KODU.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (ULKE.Text != "")
                    {
                        insStr += ", '" + ULKE.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (TEDARIKCI_KISA_AD.Text != "")
                    {
                        insStr += ", '" + TEDARIKCI_KISA_AD.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (FAX.Text != "")
                    {
                        insStr += ", '" + FAX.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (ACIL_TELNO.Text != "")
                    {
                        insStr += ", '" + ACIL_TELNO.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (TEL_NO2.Text != "")
                    {
                        insStr += ", '" + TEL_NO2.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (TEL_NO3.Text != "")
                    {
                        insStr += ", '" + TEL_NO3.Text + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (PASIF_MI.SelectedIndex == -1 || PASIF_MI.SelectedIndex == 0)
                    {
                        insStr += ", 'H'";
                    }
                    else
                    {
                        insStr += ", 'E'";
                    }

                    insStr += ", '" + LISANS_NUMARASI.Text + "'";
                    insStr += ", '" + LISANS_SIFRESI.Text + "'";

                    if (chbKATEGORI.SelectedIndex != -1)
                    {
                        insStr += ", '" + SecilenKategori() + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (image != "")
                    {
                        insStr += ", 0x" + image;
                    }

                    insStr += ")";

                    WebService service = new WebService();
                    service.SQLText = insStr;
                    service.Open();
                    if (service.errorCode == "0")
                    {
                        WebService lisansService2 = new WebService();
                        if (lisansUpKontrol)
                        {
                            lisansService2.SQLText = "UPDATE TBLOTONUM SET SON_NUMARA = '" + (sonNum + 1) + "' WHERE NUMARA_KODU = '" + DateTime.Now.ToString("yyMM") + "_LISANS'";
                        }
                        else
                        {
                            lisansService2.SQLText = "INSERT INTO TBLOTONUM(SON_NUMARA, NUMARA_KODU) VALUES('" + (sonNum + 1) + "', '" + DateTime.Now.ToString("yyMM") + "_LISANS')";
                        }
                        lisansService2.Open();

                        string kullaniciInsStr = "INSERT INTO TBLKULLANICI(LISANS_NUMARASI, KULLANICI_ADI, ADMIN_MI, SIFRE, E_POSTA, TEL_NO) VALUES('" + LISANS_NUMARASI.Text + "', '" + TEDARIKCI_KOD.Text + "', 'H', '123'";

                        if (EPOSTA.Text != "")
                        {
                            kullaniciInsStr += ", '" + EPOSTA.Text + "'";
                        }
                        else
                        {
                            kullaniciInsStr += ", NULL";
                        }

                        if (TEL_NO.Text != "")
                        {
                            kullaniciInsStr += ", '" + TEL_NO.Text + "'";
                        }
                        else
                        {
                            kullaniciInsStr += ", NULL";
                        }

                        kullaniciInsStr += ")";

                        WebService kullaniciServis = new WebService();
                        kullaniciServis.SQLText = kullaniciInsStr;
                        kullaniciServis.Open();

                        List <DefStokTip> defStokTips = DefStokTips();
                        foreach (DefStokTip stokTip in defStokTips)
                        {
                            WebService stokTipQry = new WebService();
                            stokTipQry.SQLText = "INSERT INTO TBLSTOKTIP(TIP_KODU, TIP_TANIMI, TIP_RESIM, TEDARIKCI_KODU, ET_ORAN, KIYMA_ORAN, DANA_ORAN, HINDI_ORAN, TAVUK_ORAN, YAG_ORAN, BAHARAT_ORAN, KATEGORI_KODU, PASIF_MI) " +
                                                 "VALUES('" + stokTip.tipKodu + "', '" + stokTip.tipTanimi + "', 0x" + Goto724Lib.ByteArrayToString(Goto724Lib.ImageToByteArray(stokTip.img)) + ", '" + TEDARIKCI_KOD.Text + "', " + stokTip.etOran + ", "
                                                 + stokTip.kiymaOran + ", " + stokTip.danaOran + ", " + stokTip.hindiOran + ", " + stokTip.tavukOran + ", " + stokTip.yagOran + ", " + stokTip.baharatOran + ", '" + stokTip.kategoriKodu + "', 'H')";
                            stokTipQry.Open();
                        }

                        GotoMessage.ShowMessage("Bilgi", "Kayıt Başarıyla Tamamlandı");
                        GotoMessage.ShowMessage("Bilgi", TEDARIKCI_AD.Text + " Lisans Bilgileri\nLisans Numarası: " + LISANS_NUMARASI.Text + "\nLisans Şifresi: " + LISANS_SIFRESI.Text);
                        if (Goto724Lib.adminMi)
                        {
                            PanelClear();
                            RefreshGrid();
                        }
                    }
                    else
                    {
                        GotoMessage.ShowMessage("Hata", "Kayıt Aktarılırken Hatayla Karşılaşıldı.\nHata: " + service.description);
                    }
                }
            }
            else
            {
                string mesaj = "";
                if (TEDARIKCI_KOD.Text == "")
                {
                    mesaj = "Tedarikçi Kodu";
                }
                else if (TEDARIKCI_AD.Text == "")
                {
                    mesaj = "Tedarikçi Adı";
                }
                mesaj += " Boş Olamaz!!";
                GotoMessage.ShowMessage("Bilgi", mesaj);
            }
        }