Beispiel #1
0
        private void txtDepoYeri_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                if (txtDepoYeri.Text.Trim() == "")
                {
                    MessageBox.Show("Depo yeri boş geçilemez!");
                    return;
                }

                if (!depoChecked)
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        WS_Stok.service SRV = new WS_Stok.service();

                        SRV.Url         = Utility.getWsUrl("zktmobil_stok");
                        SRV.Credentials = ProgramGlobalData.g_credential;

                        WS_Stok.ZktmobilChckStore Str    = new WS_Stok.ZktmobilChckStore();
                        WS_Stok.ZkmobilReturn[]   Return = new KoctasMobil.WS_Stok.ZkmobilReturn[0];
                        Str.EReturn = Return;
                        Str.IMatnr  = lblMatnr.Text;
                        Str.ILgort  = txtDepoYeri.Text.Trim();

                        WS_Stok.ZktmobilChckStoreResponse Response =
                            new WS_Stok.ZktmobilChckStoreResponse();
                        Response = SRV.ZktmobilChckStore(Str);

                        if (Response.EReturn.Length > 0 && Response.EReturn[0].RcCode == "E")
                        {
                            MessageBox.Show(Response.EReturn[0].RcText, "HATA!", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                            Cursor.Current = Cursors.Default;
                            return;
                        }
                        txtMiktar.Focus();
                        depoChecked = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "HATA!", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
                else
                {
                    txtMiktar.Focus();
                }
            }
        }
        private void btn_kaydet_Click(object sender, EventArgs e)
        {
            if (drMal.Rows.Count == 0)
            {
                MessageBox.Show("Kaydetmeden önce malzeme ekleyin", "HATA");
                return;
            }

            if (MessageBox.Show("Malzemeleri kaydetmek istediğinizden emin misiniz?", "BİLGİ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                try {
                    Cursor.Current = Cursors.WaitCursor;

                    WS_Stok.service         srv    = new KoctasMobil.WS_Stok.service();
                    WS_Stok.ZkmobilReturn   ret    = new KoctasMobil.WS_Stok.ZkmobilReturn();
                    WS_Stok.ZmbSendToAdrs[] topMal = new KoctasMobil.WS_Stok.ZmbSendToAdrs[drMal.Rows.Count];

                    WS_Stok.ZktmobilSendToAdress         sendAdress     = new KoctasMobil.WS_Stok.ZktmobilSendToAdress();
                    WS_Stok.ZktmobilSendToAdressResponse respSendAdress = new KoctasMobil.WS_Stok.ZktmobilSendToAdressResponse();

                    srv.Credentials = ProgramGlobalData.g_credential;
                    srv.Url         = Utility.getWsUrl("zktmobil_stok");

                    int j = 0;
                    foreach (DataRow row in drMal.Rows)
                    {
                        topMal[j]       = new KoctasMobil.WS_Stok.ZmbSendToAdrs();
                        topMal[j].Matnr = row["Matnr"].ToString();
                        topMal[j].Meins = row["Meins"].ToString();
                        topMal[j].Menge = Convert.ToDecimal(row["Menge"]);
                        topMal[j].Nlpla = row["Nlpla"].ToString();

                        j++;
                    }

                    sendAdress.EReturn       = ret;
                    sendAdress.ZmbSendToAdrs = topMal;
                    sendAdress.ImNlpla       = adres;

                    respSendAdress = srv.ZktmobilSendToAdress(sendAdress);
                    if (respSendAdress.EReturn.RcCode.ToUpper() == "E")
                    {
                        //Eger kayit sirasinda bir hata olmussa
                        MessageBox.Show(respSendAdress.EReturn.RcText, "HATA");
                    }
                    else
                    {
                        drMal.Clear();
                        malzemeNo    = "";
                        malzemeTanim = "";
                        malzemeAdet  = 0;
                        malzemeBirim = "";
                        MessageBox.Show("Malzemeler kaydedildi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
        private void btn_Ekle_Click_1(object sender, EventArgs e)
        {
            if (txtHedefAdres.Text.Trim() == "")
            {
                return;
            }
            else if (cmbDepoYeri.SelectedIndex == -1)
            {
                MessageBox.Show("Depo Yeri Seçiniz.", "HATA");
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                WS_Stok.service           srv       = new KoctasMobil.WS_Stok.service();
                WS_Stok.ZkmobilReturn     ret       = new KoctasMobil.WS_Stok.ZkmobilReturn();
                WS_Stok.ZmbTransBtwAdrs[] transData = new KoctasMobil.WS_Stok.ZmbTransBtwAdrs[1];


                WS_Stok.ZktmobilTransBtwAdrs         trans = new KoctasMobil.WS_Stok.ZktmobilTransBtwAdrs();
                WS_Stok.ZktmobilTransBtwAdrsResponse resp  = new KoctasMobil.WS_Stok.ZktmobilTransBtwAdrsResponse();

                trans.EReturn = ret;

                transData[0] = new KoctasMobil.WS_Stok.ZmbTransBtwAdrs();

                transData[0].DNlpla = txtHedefAdres.Text.Trim().ToUpper();
                transData[0].Lgort  = cmbDepoYeri.SelectedItem.ToString();
                transData[0].Matnr  = malzemeNo;
                transData[0].Menge  = malzemeAdet;
                transData[0].SNlpla = kaynakAdres;
                transData[0].Werks  = depoYerindenUretimYeriBul(cmbDepoYeri.SelectedItem.ToString());

                trans.ItData = transData;

                srv.Credentials = ProgramGlobalData.g_credential;
                srv.Url         = Utility.getWsUrl("zktmobil_stok");
                resp            = srv.ZktmobilTransBtwAdrs(trans);


                if (resp.EReturn.RcCode.ToUpper() == "E")
                {
                    //Eger kayit sirasinda bir hata olmussa
                    MessageBox.Show(resp.EReturn.RcText, "HATA");
                }
                else
                {
                    //Transfer edilen adet kaynak listeden düşülüyor...
                    for (int i = 0; i < drMal.Rows.Count; i++)
                    {
                        if (drMal.Rows[i]["Matnr"].ToString() == malzemeNo.ToString())
                        {
                            decimal mevcutAdet = Convert.ToDecimal(drMal.Rows[i]["Menge"].ToString());
                            drMal.Rows[i]["Menge"] = (mevcutAdet - malzemeAdet);
                        }
                    }

                    malzemeAdet        = 0;
                    txt_malzemeNo.Text = "";
                    txt_miktar.Text    = "";
                    txt_miktar.Enabled = false;

                    txt_birim.Text          = "";
                    txt_maktx.Text          = "";
                    txtHedefAdres.Text      = "";
                    txtHedefAdres.Enabled   = false;
                    btn_Ekle.Enabled        = false;
                    checkSatisAlani.Checked = false;

                    txt_malzemeNo.Focus();

                    grd_mal.DataSource = drMal;
                    MessageBox.Show("Transfer yapıldı.", "BİLGİ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HATA");
            } finally {
                Cursor.Current = Cursors.Default;
            }
        }