Example #1
0
        static void Main()
        {
            config       = new Settings1();
            sap          = new SAP();
            sql          = new SQL();
            logger       = new Logger(Application.StartupPath);
            lastOperator = "";

            try
            {
                steelyard = new Steelyard(config.KantarID, sql);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ayar dosyasýnda kantar ID'si hatalý, kontrol edin: " + ex.ToString());
                return;
            }

            sync       = new Sync();
            syncStart  = new ThreadStart(sync.doSync);
            syncThread = new Thread(syncStart);
            syncThread.Start();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            frmMain = new FormMain();
            frmMain.setIntegrationStatus(Common.STATUS.GRAY);
            Application.Run(frmMain);
        }
Example #2
0
        public static void createOrModifyFromSAP(
            SQL S,
            string Id,
            string Text,
            decimal SalesToleranceLow,
            decimal SalesToleranceHigh,
            string Model,
            string ComPort,
            int BaudRate,
            int DataBits,
            string Parity,
            string StopBits,
            string FreeMode,
            string Address1,
            string Address2,
            string Address3,
            string Address4,
            string Address5,
            string Address6)
        {
            // Bu kantar tanýmý var mý? Varsa güncelleyeceðiz, yoksa yaratacaðýz
            Steelyard s = new Steelyard(S);;

            bool exists = false;

            try
            {
                s      = new Steelyard(Id, S);
                exists = true;
            }
            catch (Exception ex)
            {
            }

            // Ortak parametreler
            s.text = Text;
            s.salesToleranceLow  = SalesToleranceLow;
            s.salesToleranceHigh = SalesToleranceHigh;
            s.model       = Model;
            s.portName    = ComPort;
            s.baudRate    = BaudRate;
            s.dataBits    = DataBits;
            s.parity      = Parity;
            s.stopBits    = StopBits;
            s.testMode    = FreeMode == "X";
            s.addressLine = new string[6] {
                Address1, Address2, Address3, Address4, Address5, Address6
            };

            // Taným yoksa, yeni yaratacaðýz
            if (!exists)
            {
                s.id = Id;
            }

            // Kaydet
            s.save();
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = false;
            Steelyard sy = new Steelyard(Program.config.KantarID, Program.sql);

            sy.weight = weightMain.weight;
            sy.savePlatformWeight();
            btnSave.Enabled = true;
        }
Example #4
0
 private void setDefaultValues()
 {
     platformWeight = Program.steelyard.weight;
     _kanid         = Program.steelyard;
 }
Example #5
0
        private void sapToSql()
        {
            //////////
            // SAP'den verileri çekelim
            //////////

            SAPWAS.ZGURKAN_S_KNA1[] kna1;
            SAPWAS.ZGURKAN_S_LFA1[] lfa1;
            SAPWAS.ZGURKAN_S_LIKP[] likp;
            SAPWAS.ZGURKAN_S_MARA[] mara;
            SAPWAS.ZGURKAN01[]      kantar;

            sap.getSapData(out kna1, out lfa1, out likp, out mara, out kantar);

            //////////
            // Çektiðimiz verileri sýrayla aktaralým
            //////////

            // Müþteriler
            sql.beginTransaction();

            sql.initializeStoredProcedure("SP_KNA1_PURGE");
            sql.executeStoredProcedureNonQuery();

            for (int n = 0; n < kna1.Length; n++)
            {
                sql.initializeStoredProcedure("SP_KNA1_INSERT");
                sql.addStoredProcedureParameter("@KUNNR", kna1[n].KUNNR);
                sql.addStoredProcedureParameter("@NAME1_TR", kna1[n].NAME1_TR);
                sql.addStoredProcedureParameter("@NAME1_AR", kna1[n].NAME1_AR);
                sql.addStoredProcedureParameter("@ADDRE_TR", kna1[n].ADDRE_TR);
                sql.addStoredProcedureParameter("@ADDRE_AR", kna1[n].ADDRE_AR);
                sql.executeStoredProcedureNonQuery();
            }

            sql.commitTransaction();

            // Satýcýlar
            sql.beginTransaction();

            sql.initializeStoredProcedure("SP_LFA1_PURGE");
            sql.executeStoredProcedureNonQuery();

            for (int n = 0; n < lfa1.Length; n++)
            {
                sql.initializeStoredProcedure("SP_LFA1_INSERT");
                sql.addStoredProcedureParameter("@LIFNR", lfa1[n].LIFNR);
                sql.addStoredProcedureParameter("@NAME1_TR", lfa1[n].NAME1_TR);
                sql.addStoredProcedureParameter("@NAME1_AR", lfa1[n].NAME1_AR);
                sql.addStoredProcedureParameter("@VENDO", lfa1[n].VENDO);
                sql.addStoredProcedureParameter("@TRANS", lfa1[n].TRANS);
                sql.executeStoredProcedureNonQuery();
            }

            sql.commitTransaction();

            // Malzemeler
            sql.beginTransaction();

            sql.initializeStoredProcedure("SP_MARA_PURGE");
            sql.executeStoredProcedureNonQuery();

            for (int n = 0; n < mara.Length; n++)
            {
                sql.initializeStoredProcedure("SP_MARA_INSERT");
                sql.addStoredProcedureParameter("@MATNR", mara[n].MATNR);
                sql.addStoredProcedureParameter("@MAKTX_TR", mara[n].MAKTX_TR);
                sql.addStoredProcedureParameter("@MAKTX_AR", mara[n].MAKTX_AR);
                sql.addStoredProcedureParameter("@MATKL", mara[n].MATKL);
                sql.addStoredProcedureParameter("@WGBEZ_TR", mara[n].WGBEZ_TR);
                sql.addStoredProcedureParameter("@WGBEZ_AR", mara[n].WGBEZ_AR);
                sql.addStoredProcedureParameter("@SELLA", mara[n].SELLA);
                sql.addStoredProcedureParameter("@LOLIC", mara[n].LOLIC);
                sql.addStoredProcedureParameter("@LOLIM", mara[n].LOLIM);
                sql.addStoredProcedureParameter("@LOLIA", mara[n].LOLIA);
                sql.addStoredProcedureParameter("@UPLIC", mara[n].UPLIC);
                sql.addStoredProcedureParameter("@UPLIM", mara[n].UPLIM);
                sql.addStoredProcedureParameter("@UPLIA", mara[n].UPLIA);
                sql.executeStoredProcedureNonQuery();
            }

            sql.commitTransaction();


            // Teslimatlar
            sql.beginTransaction();

            sql.initializeStoredProcedure("SP_LIKP_PURGE");
            sql.executeStoredProcedureNonQuery();

            for (int n = 0; n < likp.Length; n++)
            {
                sql.initializeStoredProcedure("SP_LIKP_INSERT");
                sql.addStoredProcedureParameter("@VBELN", likp[n].VBELN);
                sql.addStoredProcedureParameter("@MATNR", likp[n].MATNR);
                sql.addStoredProcedureParameter("@LFIMG", likp[n].LFIMG);
                sql.addStoredProcedureParameter("@MEINS", likp[n].MEINS);
                sql.addStoredProcedureParameter("@KUNWE", likp[n].KUNWE);
                sql.addStoredProcedureParameter("@LIFSP", likp[n].LIFSP);
                sql.addStoredProcedureParameter("@TRAID", likp[n].TRAID);
                sql.addStoredProcedureParameter("@TRAID_FORMATTED", new PlateNumber(likp[n].TRAID.ToString()).plateNumber);
                sql.addStoredProcedureParameter("@LFDAT", SQL.parseSapDate(likp[n].LFDAT));

                sql.executeStoredProcedureNonQuery();
            }

            sql.commitTransaction();

            // Kantarlar
            for (int n = 0; n < kantar.Length; n++)
            {
                Steelyard.createOrModifyFromSAP(
                    sql,
                    kantar[n].KANID,
                    kantar[n].KANTX,
                    kantar[n].SALOT,
                    kantar[n].SAHIT,
                    kantar[n].MODEL,
                    kantar[n].COMPO,
                    kantar[n].BAUDR,
                    kantar[n].DATAB,
                    kantar[n].PARIT,
                    kantar[n].STOPB,
                    kantar[n].FREEM,
                    kantar[n].ADRE1,
                    kantar[n].ADRE2,
                    kantar[n].ADRE3,
                    kantar[n].ADRE4,
                    kantar[n].ADRE5,
                    kantar[n].ADRE6
                    );
            }

            // Bu kadar
            sql.disconnect();
        }