Beispiel #1
0
        public static List <PickupKeyword> GetPickupKeyListFromServer()
        {
            string sql  = "select * FROM pickupkeywords";
            var    list = new List <PickupKeyword>();

            using (var conn = new MySqlConnection(Set.ConnString))
                using (var cmd = new MySqlCommand(sql, conn))
                {
                    try
                    {
                        conn.Open();
                        using (MySqlDataReader rd = cmd.ExecuteReader())
                        {
                            while (rd.Read())
                            {
                                var puk = new PickupKeyword();
                                puk.Id       = Convert.ToUInt32(rd[0]);
                                puk.OrdSysId = Convert.ToUInt32(rd[1]);
                                puk.Keyword  = Convert.ToString(rd[2]);
                                puk.LocId    = Convert.ToUInt32(rd[3]);
                                list.Add(puk);
                            }
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Error connecting to server");
                    }
                }
            return(list);
        }
Beispiel #2
0
        private void but_KeyWordSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtbox_KeyWord_Key.ToString()))
            {
                if (puk == null)
                {
                    puk          = new PickupKeyword();
                    puk.OrdSysId = ordSysId;
                }
                puk.Keyword = txtbox_KeyWord_Key.Text;
                puk.LocId   = Convert.ToUInt32(cmbbox_KeyWord_Stores.SelectedValue);


                if (PickupKeyword.UpdateKeywords(puk))
                {
                    this.Close();
                }
            }
        }
Beispiel #3
0
        public static bool UpdateKeywords(PickupKeyword puk)
        {
            string sql;

            if (puk.Id == null)
            {
                sql = "INSERT INTO pickupkeywords " +
                      "(puk_Id,puk_OrdSysId,puk_KeyWord,puk_LocId)" +
                      "VALUES(@Id,@OrdSysId,@KeyWord,@pukLocId)";
            }
            else
            {
                sql = "UPDATE pickupkeywords SET " +
                      "puk_OrdSysId=@OrdSysId, puk_KeyWord=@KeyWord, puk_LocId=@pukLocId " +
                      "WHERE puk_Id=@Id";
            }

            using (var conn = new MySqlConnection(Set.ConnString))
                using (var cmd = new MySqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@Id", puk.Id);
                    cmd.Parameters.AddWithValue("@OrdSysId", puk.OrdSysId);
                    cmd.Parameters.AddWithValue("@KeyWord", puk.Keyword);
                    cmd.Parameters.AddWithValue("@pukLocId", puk.LocId);

                    conn.Open();
                    try
                    {
                        cmd.ExecuteNonQuery();
                        if (sql.Substring(0, 6) == "INSERT")
                        {
                            puk.Id = Convert.ToUInt32(cmd.LastInsertedId);
                            Set.OrdSysList[Convert.ToInt32(puk.OrdSysId)].PuKeyWordList.Add(puk);
                        }
                        return(true);
                    }
                    catch (MySqlException)
                    {
                        MessageBox.Show("ERROR updating pickup keyword");
                        return(false);
                    }
                }
        }
Beispiel #4
0
        public static bool DelKeyWord(PickupKeyword puk)
        {
            var sql = "DELETE from pickupkeywords Where puk_Id = @Id";

            using (var conn = new MySqlConnection(Set.ConnString))
                using (var cmd = new MySqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@Id", puk.Id);
                    conn.Open();
                    try
                    {
                        cmd.ExecuteNonQuery();
                        Set.OrdSysList[Convert.ToInt32(puk.OrdSysId)].PuKeyWordList.Remove(puk);
                        return(true);
                    }
                    catch (MySqlException)
                    {
                        MessageBox.Show("ERROR deleting pickup keyword");
                        return(false);
                    }
                }
        }
Beispiel #5
0
        public static List <PickupKeyword> GetKeywordListFromServerByOrdSys(Set.OrdSysName ordSysName)
        {
            string sql = "select * FROM pickupkeywords WHERE puk_OrdSysName = '" + ordSysName.ToString() + "'";
            List <PickupKeyword> list = new List <PickupKeyword>();

            using (var conn = new MySqlConnection(Set.ConnString))
                using (var cmd = new MySqlCommand(sql, conn))
                {
                    conn.Open();
                    using (MySqlDataReader rd = cmd.ExecuteReader())
                    {
                        while (rd.Read())
                        {
                            var puk = new PickupKeyword();
                            puk.Id      = Convert.ToUInt32(rd[0]);
                            puk.Keyword = Convert.ToString(rd[1]);
                            puk.LocId   = Convert.ToUInt32(rd[2]);
                            list.Add(puk);
                        }
                    }
                }
            return(list);
        }
Beispiel #6
0
        public static void DoStartUp()
        {
            string               iniFile    = Directory.GetCurrentDirectory() + @"\HotsSavedData.xml";
            string               connString = "server=69.89.31.188;uid=hitephot_don;database=hitephot_hots;port=3306;password=Hite1985;";
            LocalSettings        savedSet;
            List <OrderSystem>   webOrdSysList;
            List <PickupKeyword> pukList;
            List <Locations>     locList;


            Data.LogEvents(1, "Hots Downloader started");
            savedSet = LocalSettings.readSettingsfromDisk(iniFile);
            Set.SetSettingsFromReadFile(savedSet, iniFile, connString);//fills default inifile & connstring if blank

            locList     = Locations.GetLocationList();
            Set.LocList = locList;

            if (savedSet != null)
            {
                Set.ThisLocation = Locations.GetLocById(savedSet.SelectedPickupLocationId);
            }



            Set.MakeOrdSysList();
            webOrdSysList = OrderSystem.GetOrdSysListFromServer();
            while (webOrdSysList.Count < 3)
            {
                webOrdSysList.Add(new OrderSystem());
            }

            pukList = PickupKeyword.GetPickupKeyListFromServer();
            FillOrdSysProperties(Set.OrdSysList, webOrdSysList, pukList, savedSet);

            Watchers.MakeFolderWatchers();
        }
Beispiel #7
0
 private void but_KeyWordDel_Click(object sender, EventArgs e)
 {
     PickupKeyword.DelKeyWord(puk);
     Close();
 }
Beispiel #8
0
 public EditKeywordForm(UInt32 _ordSysId, PickupKeyword _puk)
 {
     InitializeComponent();
     puk      = _puk;
     ordSysId = _ordSysId;
 }