Esempio n. 1
0
    public string insertPrefix(PrefixData dataInsert)
    {
        string response = "";

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into PREFIX(PREFIX_CODE, PREFIX_THAI, PREFIX_ENG) Values('" + dataInsert.Prefix_Code + "','" + dataInsert.Prefix_Thai + "','" + dataInsert.Prefix_Eng + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }
        return(response);
    }
Esempio n. 2
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        string            sql    = "Select * From PREFIX Where PREFIX_CODE='" + txtPREFIX_CODE.Text + "'";
        List <PrefixData> chkDup = new Prefix().getPrefixManual(sql);

        if (chkDup.Count > 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('รหัสคำนำหน้าชื่อซ้ำ!');", true);
        }
        else
        {
            PrefixData data = new PrefixData();

            data.Prefix_Code = txtPREFIX_CODE.Text;
            data.Prefix_Thai = txtPREFIX_THAI.Text;
            data.Prefix_Eng  = txtPREFIX_ENG.Text;

            string result = "";

            result = new Prefix().insertPrefix(data);

            if (result == "OK")
            {
                Response.Redirect("list_Prefix.aspx");
            }
        }
    }
Esempio n. 3
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        PrefixData data = new PrefixData();

        data.Prefix_Code = txtPREFIX_CODE.Text;
        data.Prefix_Thai = txtPREFIX_THAI.Text;
        data.Prefix_Eng  = txtPREFIX_ENG.Text;

        string result = "";

        try
        {
            result = new Prefix().updatePrefix(data);

            if (result == "OK")
            {
                Response.Redirect("list_Prefix.aspx");
            }
            else
            {
                Response.Redirect("list_Prefix.aspx");
            }
        }
        catch (Exception E)
        {
            //string response = E.Message.ToString();
            //HttpContext.Current.Session["response"] = "Unit Test: " + response;
            //HttpContext.Current.Response.Redirect("err_response.aspx");
        }
    }
Esempio n. 4
0
    public PrefixData getPrefix(String Prefix_Code)
    {
        PrefixData prefix_data = new PrefixData();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();
        string        response  = "";

        try
        {
            oracleObj.SelectCommand = "Select * From PREFIX Where PREFIX_CODE='" + Prefix_Code + "'";
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                prefix_data.Prefix_Code = rowData["PREFIX_CODE"].ToString();
                prefix_data.Prefix_Thai = rowData["PREFIX_THAI"].ToString();
                prefix_data.Prefix_Eng  = rowData["PREFIX_ENG"].ToString();
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }
        return(prefix_data);
    }
Esempio n. 5
0
    public string updatePrefix(PrefixData updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Update PREFIX Set PREFIX_THAI = '" + updateData.Prefix_Thai + "', PREFIX_ENG='" + updateData.Prefix_Eng + "' Where PREFIX_CODE='" + updateData.Prefix_Code + "'";

        oracleObj.UpdateCommand = sql;

        try
        {
            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                /*=============================*/
                code = Request.QueryString["token"];

                if (!Page.IsPostBack)
                {
                    data = obj.getPrefix(code);

                    txtPREFIX_CODE.Text = data.Prefix_Code;
                    txtPREFIX_THAI.Text = data.Prefix_Thai;
                    txtPREFIX_ENG.Text  = data.Prefix_Eng;
                }

                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
 private void packHits()
 {
     for (int i = hitTree.Count - 1; i >= 0; i--)
     {
         if (hitTree[i].Data.Location.X == Int32.MaxValue)
         {
             ////mark as used
             hitTree[i].Id = -1;
             if (hitTree[i].Parent >= 0)
             {
                 ////add attribute to parent
                 hitTree[hitTree[i].Parent].Data.Attributes.Add(hitTree[i].Data.Territory);
             }
             //end;
         }
     }
     ////add to output
     for (int i = hitTree.Count - 1; i >= 0; i--)
     {
         if (hitTree[i].Id > -1)
         {
             PrefixData hit = new PrefixData();
             hit.Location.X = Int32.MaxValue;
             hit.Location.Y = Int32.MaxValue;
             hit            = mergePrefixData(hit, hitTree[i]);
             hitList.Add(hit);
         }
     }
     hitTree = null;
 }
        private PrefixData getAdifItem(int adif)
        {
            PrefixData result = null;

            for (int i = 0; i < prefixList.Entries.Count; i++)
            {
                if (prefixList.Entries[i].Kind.Equals(PrefixKind.DXCC) && prefixList.Entries[i].Data.ADIF.Equals(adif.ToString()))
                {
                    result = prefixList.Entries[i].Data;
                    break;
                }
            }
            return(result);
        }
Esempio n. 9
0
    //Pongsarun 26/2/2016: use for config system
    public List <PrefixData> getPrefixManual(string sql)
    {
        List <PrefixData> prefix_data = new List <PrefixData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = sql;
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            PrefixData prefix = new PrefixData();
            prefix.Prefix_Code = rowData["PREFIX_CODE"].ToString();
            prefix.Prefix_Thai = rowData["PREFIX_THAI"].ToString();
            prefix.Prefix_Eng  = rowData["PREFIX_ENG"].ToString();
            prefix_data.Add(prefix);
        }

        return(prefix_data);
    }
        private void resolveCallsign(string callsign)
        {
            if (callsign.StartsWith(ADIF_MARKER))
            {
                int adif = Convert.ToInt32(callsign.Substring(ADIF_MARKER.Length));
                if (adif > 0)
                {
                    PrefixData prefixData = getAdifItem(adif);
                    if (prefixData != null)
                    {
                        hitList.Add(prefixData);
                    }
                }
            }
            else
            {
                int x = AfreetConstants.Chars.IndexOf(callsign[0]);
                int y = AfreetConstants.Chars.IndexOf(callsign[1]);
                List <PrefixEntry> arr = prefixList.Index[x, y];

                for (int i = 0; i < arr.Count; i++)
                {
                    try
                    {
                        if (tryMask(arr[i], true, callsign))
                        {
                            PrefixEntry hitEntry = addHit(arr[i], -1);
                            addSubHits(arr[i], hitEntry.Id, callsign);
                        }
                    }
                    catch
                    {
                    }
                }
                packHits();
            }

            // order hist list by prefix
            hitList = hitList.OrderBy(e => e.Prefix).ToList <PrefixData>();
        }
        private PrefixData mergePrefixData(PrefixData destination, PrefixEntry source)
        {
            source.Id = -1;
            switch (source.Kind)
            {
            case PrefixKind.DXCC:
            {
                destination.Territory = source.Data.Territory;
                break;
            }

            case PrefixKind.Province:
            {
                destination.Province = (String.IsNullOrEmpty(destination.Province)) ?
                                       source.Data.Territory :
                                       String.Format("{0}, {1}", source.Data.Territory, destination.Province);
                break;
            }

            case PrefixKind.City:
            {
                destination.City = source.Data.Territory;
                break;
            }

            case PrefixKind.Station:
            {
                if (source.Data.Location.X != Int32.MaxValue)
                {
                    destination.City = source.Data.Territory;
                }
                break;
            }
            }
            ////set location if it was not set by the child
            if (destination.Location.X == Int32.MaxValue)
            {
                destination.Location = source.Data.Location;
            }
            ////copy fields from Src to Dst
            if (source.Data.Location.X != Int32.MaxValue)
            {
                if (String.IsNullOrEmpty(destination.Prefix))
                {
                    destination.Prefix = source.Data.Prefix;
                }
                if (String.IsNullOrEmpty(destination.CQ))
                {
                    destination.CQ = source.Data.CQ;
                }
                if (String.IsNullOrEmpty(destination.ITU))
                {
                    destination.ITU = source.Data.ITU;
                }
                if (String.IsNullOrEmpty(destination.Continent))
                {
                    destination.Continent = source.Data.Continent;
                }
                if (String.IsNullOrEmpty(destination.TZ))
                {
                    destination.TZ = source.Data.TZ;
                }
                if (String.IsNullOrEmpty(destination.ADIF))
                {
                    destination.ADIF = source.Data.ADIF;
                }
                if (String.IsNullOrEmpty(destination.ProvinceCode))
                {
                    destination.ProvinceCode = source.Data.ProvinceCode;
                }
            }
            ////copy attributes
            destination.Attributes.AddRange(source.Data.Attributes);
            ////add missing data from Src's parents
            if (source.Parent > -1)
            {
                mergePrefixData(destination, hitTree[source.Parent]);
            }
            return(destination);
        }