예제 #1
0
        protected void firstButton_Click(object sender, EventArgs e)
        {
            SpacymenParty spacymenParty = spacymenPartyManager.GetAllSpacymenParties(0);

            GetValueFromDatabase(spacymenParty);
            Session["active"] = 0;
        }
        //public Party GetSpacymenParty(int i)
        //{
        //    return spacymenPartyGateway.GetSpacymenParty(i);
        //}

        public string Save(SpacymenParty spacymenParty)
        {
            if (spacymenPartyGateway.Insert(spacymenParty) > 0)
            {
                return("Saved Successfully!!");
            }
            return("Could Not Save data in Database!!");
        }
예제 #3
0
 private void GetValueFromDatabase(SpacymenParty spacymenParty)
 {
     districtNameDropDownList.Text  = spacymenParty.DistrictName;
     partyCodeTextBox.Text          = spacymenParty.SpacymenPartyCode;
     partyNameTextBox.Text          = spacymenParty.SpacymenPartyName;
     partyAddressTextArea.InnerText = spacymenParty.SpacymenPartyAddress;
     schoolNameTextBox.Text         = spacymenParty.SchoolName;
 }
예제 #4
0
 private static void GetAllDataFromDatabase(SpacymenParty spacymenParty, SqlDataReader reader)
 {
     spacymenParty.SpacymenPartyId      = int.Parse(reader["id"].ToString());
     spacymenParty.DistrictName         = reader["district_id"].ToString();
     spacymenParty.SpacymenPartyCode    = reader["spacymenParty_code"].ToString();
     spacymenParty.SpacymenPartyName    = reader["spacymenParty_name"].ToString();
     spacymenParty.SpacymenPartyAddress = reader["spacymenParty_address"].ToString();
     spacymenParty.SchoolName           = reader["school_name"].ToString();
 }
예제 #5
0
        protected void lastButton_Click(object sender, EventArgs e)
        {
            List <SpacymenParty> spacymenPartyList = (List <SpacymenParty>)(Session["spacymenParty"]);
            int           x             = spacymenPartyList.Count - 1;
            SpacymenParty spacymenParty = spacymenPartyManager.GetAllSpacymenParties(x);

            GetValueFromDatabase(spacymenParty);
            Session["active"] = x;
        }
예제 #6
0
        //public Party GetSpacymenParty(int i)
        //{
        //    SqlConnection connection = new SqlConnection(connectionString);
        //    string query = "SELECT * FROM tbl_party WHERE id=" + i;
        //    SqlCommand command = new SqlCommand(query, connection);
        //    connection.Open();
        //    SqlDataReader reader = command.ExecuteReader();
        //    Party p = new Party();
        //    while (reader.Read())
        //    {
        //        p.PartyId = int.Parse(reader["id"].ToString());
        //        p.PartyCode =  reader["party_code"].ToString();
        //        p.PartyName =  reader["party_name"].ToString();
        //        p.PartyAddress = reader["party_address"].ToString();

        //    }
        //    reader.Close();
        //    connection.Close();
        //    return p;
        //}

        public int Insert(SpacymenParty spacymenParty)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "INSERT INTO tbl_spacymenParty VALUES('" + spacymenParty.DistrictName + "','" +
                                       spacymenParty.SpacymenPartyCode + "','" + spacymenParty.SpacymenPartyName + "','" +
                                       spacymenParty.SpacymenPartyAddress + "','" + spacymenParty.SchoolName + "')";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
예제 #7
0
        protected void previousButton_Click(object sender, EventArgs e)
        {
            int active = (int)Session["active"];

            active--;
            List <SpacymenParty> spacymenPartyList = (List <SpacymenParty>)(Session["spacymenParty"]);

            if (active <= -1)
            {
                active = spacymenPartyList.Count - 1;
            }
            SpacymenParty spacymenParty = spacymenPartyManager.GetAllSpacymenParties(active);

            GetValueFromDatabase(spacymenParty);
            Session["active"] = active;
        }
예제 #8
0
        public SpacymenParty GetAllSpacymenParties(int i)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_spacymenParty ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader        = command.ExecuteReader();
            SpacymenParty spacymenParty = new SpacymenParty();

            while (reader.Read())
            {
                GetAllDataFromDatabase(spacymenParty, reader);
            }
            reader.Close();
            connection.Close();
            return(spacymenParty);
        }
예제 #9
0
        //protected void districtNameDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    int id = int.Parse(districtNameDropDownList.SelectedValue);
        //    Party spacymenParty = spacymenPartyManager.GetSpacymenParty(id);
        //    partyCodeTextBox.Text = spacymenParty.PartyCode;
        //    partyNameTextBox.Text = spacymenParty.PartyName;
        //    partyAddressTextArea.InnerText = spacymenParty.PartyAddress;
        //}

        private string LoadNextPartyCode()
        {
            SpacymenParty spacymenParty = spacymenPartyManager.GetNextPartyCode();
            string        spCode        = spacymenParty.SpacymenPartyCode;
            int           c;

            if (spCode == null)
            {
                c = 1;
            }
            else
            {
                c = (spCode[3] - '0') * 10 + (spCode[4] - '4') + 1;
            }
            string nextCode = "Spc" + c.ToString("00");

            return(nextCode);
        }
예제 #10
0
        public SpacymenParty GetNextCode()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_spacymenParty ORDER BY id DESC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            SpacymenParty sp     = new SpacymenParty();

            while (reader.Read())
            {
                sp.SpacymenPartyId   = int.Parse(reader["id"].ToString());
                sp.SpacymenPartyCode = reader["spacymenParty_code"].ToString();
            }
            reader.Close();
            connection.Close();
            return(sp);
        }
예제 #11
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            SpacymenParty spacymenParty = new SpacymenParty();

            spacymenParty.DistrictName         = districtNameDropDownList.SelectedValue;
            spacymenParty.SpacymenPartyCode    = partyCodeTextBox.Text;
            spacymenParty.SpacymenPartyName    = partyNameTextBox.Text;
            spacymenParty.SpacymenPartyAddress = partyAddressTextArea.InnerText;
            spacymenParty.SchoolName           = schoolNameTextBox.Text;
            if (districtNameDropDownList.Text == "" || partyCodeTextBox.Text == "" || partyNameTextBox.Text == "" ||
                partyAddressTextArea.InnerText == "" || schoolNameTextBox.Text == "")
            {
                message.InnerText = "All Fields are Required!!";
            }
            else
            {
                messageLabel.InnerText = spacymenPartyManager.Save(spacymenParty);
            }
        }
예제 #12
0
        public List <SpacymenParty> GetAllSpacymenPartyList()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_spacymenParty";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader        reader            = command.ExecuteReader();
            List <SpacymenParty> spacymenPartyList = new List <SpacymenParty>();

            while (reader.Read())
            {
                SpacymenParty spacymenParty = new SpacymenParty();
                GetAllDataFromDatabase(spacymenParty, reader);
                spacymenPartyList.Add(spacymenParty);
            }
            reader.Close();
            connection.Close();
            return(spacymenPartyList);
        }