예제 #1
0
        private void SiparisListeRefresh()
        {
            WebService siparisListeQry = new WebService();

            siparisListeQry.SQLText = "SELECT SIP.BELGE_NO " +
                                      ", MUS.MUSTERI_ADI " +
                                      ", MUS.SEHIR " +
                                      ", MUS.POSTA_KODU " +
                                      ", LEFT(CONVERT(VARCHAR(10), TESLIM_TARIHI, 104), 6) + RIGHT(CONVERT(VARCHAR(10), TESLIM_TARIHI, 104), 2) AS TESLIM_TARIHI " +
                                      ", DATEDIFF(DAY, GETDATE(), TESLIM_TARIHI) AS SURE " +
                                      ", SIP.ACIKLAMA " +
                                      ", STOK.STOK_ADI " +
                                      ", PAKET.MIKTAR AS SIPARIS_KG " +
                                      ", HAR.MIKTAR ADET " +
                                      ", PAKET.MIKTAR* HAR.MIKTAR AS TOPLAM " +
                                      ", CASE DURUM " +
                                      "    WHEN 0 THEN 'Yeni Sipariş' " +
                                      "    WHEN 2 THEN 'Sipariş Alındı' " +
                                      "    WHEN 3 THEN 'Üretimde' " +
                                      "    WHEN 4 THEN 'Kargoda' " +
                                      "    WHEN 1 THEN 'Teslim Edildi' " +
                                      "    WHEN 5 THEN 'İptal Edildi' " +
                                      "    WHEN 7 THEN 'Stoğa Alındı' " +
                                      "    ELSE '' END AS DURUM " +
                                      ", 'Durum Güncelle' AS BUTTON " +
                                      "FROM TBLSIPARIS SIP, TBLMUSTERI MUS, TBLSIPARISHAR HAR, TBLSTOK STOK, TBLSTOKPAKET PAKET " +
                                      "WHERE MUS.MUSTERI_KODU = SIP.MUSTERI_KODU " +
                                      "AND SIP.BELGE_NO = HAR.BELGE_NO " +
                                      "AND HAR.STOK_KODU = STOK.STOK_KODU " +
                                      "AND HAR.PAKET_KODU = PAKET.PAKET_KODU " +
                                      "AND ISNULL(DURUM, 0) NOT IN (5, 6) ";
            if (SURESI.Text != "")
            {
                siparisListeQry.SQLText += "AND DATEDIFF(DAY, GETDATE(), TESLIM_TARIHI) = " + SURESI.Text + " ";
            }
            if (KATEGORI.SelectedIndex != -1)
            {
                siparisListeQry.SQLText += "AND HAR.KATEGORI_KODU = '" + KATEGORI.GetString() + "' ";
                if (STOK_TIPI.SelectedIndex != -1)
                {
                    siparisListeQry.SQLText += "AND STOK.STOK_TIPI = '" + STOK_TIPI.GetString() + "' ";
                }
            }
            if (MUSTERI_KODU.Text != "")
            {
                siparisListeQry.SQLText += "AND SIP.MUSTERI_KODU = '" + MUSTERI_KODU.Text + "' ";
            }
            if (DURUM.CheckedItems.Count > 0)
            {
                string inList = "";
                for (int i = 0; i < DURUM.CheckedItems.Count; i++)
                {
                    switch (DURUM.CheckedItems[i].ToString())
                    {
                    case "Sipariş Alındı":
                        inList += "2,";
                        break;

                    case "Üretimde":
                        inList += "3,";
                        break;

                    case "Stoğa Alındı":
                        inList += "7,";
                        break;
                    }
                }
                siparisListeQry.SQLText += "AND DURUM IN(" + inList.Substring(0, inList.Length - 1) + ") ";
            }
            else
            {
                siparisListeQry.SQLText += "AND DURUM NOT IN(0, 2, 3, 4, 1, 5, 7) ";
            }
            siparisListeQry.SQLText += "AND SIP.TEDARIKCI_KODU = '" + Goto724Lib.tedarikciKodu + "' ORDER BY DATEDIFF(DAY, GETDATE(), TESLIM_TARIHI)";
            siparisListeQry.Open();
            grdSiparisListe.Open(siparisListeQry.dataSet);
            dsSip = siparisListeQry.dataSet;
        }
예제 #2
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (STOK_KOD.Text != "" && STOK_AD.Text != "" && STOK_KATEGORI.Text != "" && STOK_TIPI.Text != "")
            {
                WebService kntlService = new WebService();
                kntlService.SQLText = "SELECT STOK_KODU FROM TBLSTOK WHERE STOK_KODU = '" + STOK_KOD.Text + "' AND TEDARIKCI_KODU = '" + Goto724Lib.tedarikciKodu + "'";
                kntlService.Open();
                if (kntlService.DataCount() > 0)
                {
                    string image = "";
                    if (imageChanged && !Goto724Lib.isNoImage(STOK_RESIM.Image))
                    {
                        image = Goto724Lib.ByteArrayToString(Goto724Lib.ImageToByteArray(STOK_RESIM.Image));
                    }

                    string updStr = "UPDATE TBLSTOK SET STOK_ADI = '" + STOK_AD.Text + "', TEDARIKCI_KODU = '" + Goto724Lib.tedarikciKodu + "'";

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

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

                    if (STOK_KATEGORI.GetString() != "")
                    {
                        updStr += ", KATEGORI_KODU = '" + STOK_KATEGORI.GetString() + "'";
                    }
                    else
                    {
                        updStr += ", KATEGORI_KODU = 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 (ACIKLAMA3.Text != "")
                    {
                        updStr += ", ACIKLAMA_3 = '" + ACIKLAMA3.Text + "'";
                    }
                    else
                    {
                        updStr += ", ACIKLAMA_3 = NULL";
                    }

                    if (ALIS_FIYAT1.Text != "")
                    {
                        updStr += ", ALIS_FIYAT1 = " + Goto724Lib.RemoveChar(ALIS_FIYAT1.Text, '.').Replace(',', '.') + "";
                    }
                    else
                    {
                        updStr += ", ALIS_FIYAT1 = NULL";
                    }

                    if (SATIS_FIYAT1.Text != "")
                    {
                        updStr += ", SATIS_FIYAT1 = " + Goto724Lib.RemoveChar(SATIS_FIYAT1.Text, '.').Replace(',', '.') + "";
                    }
                    else
                    {
                        updStr += ", SATIS_FIYAT1 = NULL";
                    }

                    for (int i = 0; i < grdStokFiyat.Rows.Count; i++)
                    {
                        if (grdStokFiyat.Rows[i].Cells["grdFiyat"].Value != null)
                        {
                            updStr += ", SATIS_FIYAT" + (i + 2) + " = " + Goto724Lib.RemoveChar(grdStokFiyat.Rows[i].Cells["grdFiyat"].Value.ToString(), '.').Replace(',', '.');
                        }
                        else
                        {
                            updStr += ", SATIS_FIYAT" + (i + 2) + " = 0";
                        }
                    }

                    //if (ALIS_FIYAT1.Text != "") updStr += ", ALIS_FIYAT1 = '" + ALIS_FIYAT1.Text + "'";
                    //else updStr += ", ALIS_FIYAT1 = NULL";

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

                    if (STOK_KATEGORI.Text == "Döner Kebap")
                    {
                        if (grdStokOran.Rows[0].Cells["grdEt"].Value == null)
                        {
                            updStr += ", ET_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", ET_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdEt"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdKiyma"].Value == null)
                        {
                            updStr += ", KIYMA_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", KIYMA_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdKiyma"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdDana"].Value == null)
                        {
                            updStr += ", DANA_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", DANA_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdDana"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdSutDana"].Value == null)
                        {
                            updStr += ", SUT_DANA_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", SUT_DANA_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdSutDana"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdHindi"].Value == null)
                        {
                            updStr += ", HINDI_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", HINDI_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdHindi"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdTavuk"].Value == null)
                        {
                            updStr += ", TAVUK_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", TAVUK_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdTavuk"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdYag"].Value == null)
                        {
                            updStr += ", YAG_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", YAG_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdYag"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdBaharat"].Value == null)
                        {
                            updStr += ", BAHARAT_ORAN = 0";
                        }
                        else
                        {
                            updStr += ", BAHARAT_ORAN = " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdBaharat"].Value) * 100).ToString().Replace(',', '.');
                        }
                    }

                    updStr += " WHERE STOK_KODU = '" + STOK_KOD.Text + "' AND TEDARIKCI_KODU = '" + Goto724Lib.tedarikciKodu + "'";

                    WebService service = new WebService();
                    service.SQLText = updStr;
                    service.Open();
                    if (service.errorCode == "0")
                    {
                        GotoMessage.ShowMessage("Bilgi", "Kayıt Düzenleme Tamamlandı");
                        PanelClear();
                        RefreshGrid();
                    }
                    else
                    {
                        GotoMessage.ShowMessage("Hata", "Kayıt Aktarılırken Hatayla Karşılaşıldı.\nHata: " + service.description);
                    }
                }
                else
                {
                    string image = "";
                    if (imageChanged && !Goto724Lib.isNoImage(STOK_RESIM.Image))
                    {
                        image = Goto724Lib.ByteArrayToString(Goto724Lib.ImageToByteArray(STOK_RESIM.Image));
                    }

                    string insStr = "INSERT INTO TBLSTOK(STOK_KODU, STOK_ADI, TEDARIKCI_KODU, STOK_TIPI, KATEGORI_KODU, ACIKLAMA_1, ACIKLAMA_2, ACIKLAMA_3, ALIS_FIYAT1, SATIS_FIYAT1, ET_ORAN, KIYMA_ORAN, DANA_ORAN, SUT_DANA_ORAN, HINDI_ORAN, TAVUK_ORAN, YAG_ORAN, BAHARAT_ORAN, SATIS_FIYAT2, SATIS_FIYAT3, SATIS_FIYAT4, SATIS_FIYAT5, SATIS_FIYAT6, SATIS_FIYAT7, SATIS_FIYAT8, PASIF_MI";
                    if (image != "")
                    {
                        insStr += ", STOK_RESIM) ";
                    }
                    else
                    {
                        insStr += ")";
                    }
                    insStr += "VALUES ('" + STOK_KOD.Text + "', '" + STOK_AD.Text + "', '" + Goto724Lib.tedarikciKodu + "'";

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

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

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

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

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

                    if (ALIS_FIYAT1.Text != "")
                    {
                        insStr += ", '" + Goto724Lib.RemoveChar(ALIS_FIYAT1.Text, '.').Replace(',', '.') + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (SATIS_FIYAT1.Text != "")
                    {
                        insStr += ", '" + Goto724Lib.RemoveChar(SATIS_FIYAT1.Text, '.').Replace(',', '.') + "'";
                    }
                    else
                    {
                        insStr += ", NULL";
                    }

                    if (STOK_KATEGORI.Text == "Döner Kebap")
                    {
                        if (grdStokOran.Rows[0].Cells["grdEt"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdEt"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdKiyma"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdKiyma"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdDana"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdDana"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdSutDana"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdSutDana"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdHindi"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdHindi"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdTavuk"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdTavuk"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdYag"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdYag"].Value) * 100).ToString().Replace(',', '.');
                        }
                        if (grdStokOran.Rows[0].Cells["grdBaharat"].Value == null)
                        {
                            insStr += ", 0";
                        }
                        else
                        {
                            insStr += ", " + (Convert.ToDouble(grdStokOran.Rows[0].Cells["grdBaharat"].Value) * 100).ToString().Replace(',', '.');
                        }
                    }
                    else
                    {
                        insStr += ",0,0,0,0,0,0,0,0";
                    }

                    for (int i = 0; i < grdStokFiyat.Rows.Count; i++)
                    {
                        if (grdStokFiyat.Rows[i].Cells["grdFiyat"].Value != null)
                        {
                            insStr += ", " + Goto724Lib.RemoveChar(grdStokFiyat.Rows[i].Cells["grdFiyat"].Value.ToString(), '.').Replace(',', '.');
                        }
                        else
                        {
                            insStr += ", 0";
                        }
                    }

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

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

                    insStr += ")";

                    WebService service = new WebService();
                    service.SQLText = insStr;
                    service.Open();
                    if (service.errorCode == "0")
                    {
                        if (STOK_KATEGORI.Text == "Döner Kebap")
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                WebService paketService = new WebService();
                                paketService.SQLText = "INSERT INTO TBLSTOKPAKET(PAKET_KODU, STOK_KODU, BIRIM_KODU, TEDARIKCI_KODU, MIKTAR, ACIKLAMA)" +
                                                       "VALUES('" + STOK_KOD.Text + "" + (i + 1).ToString("000") + "', '" + STOK_KOD.Text + "', 'KG', '" + Goto724Lib.tedarikciKodu + "', " + ((i + 1) * 5) + ", '" + ((i + 1) * 5) + " Kg" + "')";
                                paketService.Open();
                            }
                        }

                        GotoMessage.ShowMessage("Bilgi", "Kayıt Başarıyla Tamamlandı");
                        PanelClear();
                        RefreshGrid();
                    }
                    else
                    {
                        GotoMessage.ShowMessage("Hata", "Kayıt Aktarılırken Hatayla Karşılaşıldı.\nHata: " + service.description);
                    }
                }
            }
            else
            {
                string mesaj = "";
                if (STOK_KOD.Text == "")
                {
                    mesaj = "Stok Kodu";
                }
                else if (STOK_AD.Text == "")
                {
                    mesaj = "Stok Adı";
                }
                else if (STOK_KATEGORI.Text == "")
                {
                    mesaj = "Kategori";
                }
                else if (STOK_TIPI.Text == "")
                {
                    mesaj = "Stok Tipi";
                }
                mesaj += " Boş Olamaz!!";
                GotoMessage.ShowMessage("Bilgi", mesaj);
            }
        }