Пример #1
0
        public CarrierEntity GetCarrier(Int32 M_Carrier_Slno)
        {
            String updateQuery = @"Select * From  [M_Carrier]
                            Where [M_Carrier_Slno] = @M_Carrier_Slno";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = updateQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Carrier_Slno", M_Carrier_Slno);


                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlDataReader dataReader =
                    cmd.ExecuteReader(CommandBehavior.CloseConnection);

                DataTable dataTable = new DataTable();
                dataTable.Load(dataReader);
                CarrierEntity existingcarrier = new CarrierEntity();
                foreach (DataRow row in dataTable.Rows)
                {
                    existingcarrier.M_Carrier_Slno  = Convert.ToInt32(row["M_Carrier_Slno"]);
                    existingcarrier.M_Carrier_Name  = Convert.ToString(row["M_Carrier_Name"]);
                    existingcarrier.M_Carrier_Sname = Convert.ToString(row["M_Carrier_Sname"]);
                }

                return(existingcarrier);
            }
        }
Пример #2
0
        protected void ibtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow   gvRow          = (GridViewRow)((ImageButton)sender).NamingContainer;
            Int32         M_Carrier_Slno = Convert.ToInt32(gvCarrier.DataKeys[gvRow.RowIndex].Value);
            CarrierEntity carrier        = GetCarrier(M_Carrier_Slno);

            // Now set value to modal popup
            carrieridEditpopup.Value          = carrier.M_Carrier_Slno.ToString();
            txtcarriernameEditpopup.Text      = carrier.M_Carrier_Name;
            txtcarriershortnameEditpopup.Text = carrier.M_Carrier_Sname;
            mpeCarrierEditpopup.Show();
        }
Пример #3
0
        protected void ibtnView_Click(object sender, ImageClickEventArgs e)
        {
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Successfully')", true);

            GridViewRow   gvRow          = (GridViewRow)((ImageButton)sender).NamingContainer;
            Int32         M_Carrier_Slno = Convert.ToInt32(gvCarrier.DataKeys[gvRow.RowIndex].Value);
            CarrierEntity carrier        = GetCarrier(M_Carrier_Slno);

            // Now set value to modal popup
            carrieridViewpopup.Value  = carrier.M_Carrier_Slno.ToString();
            viewcarriername.Text      = carrier.M_Carrier_Name;
            viewcarriershortname.Text = carrier.M_Carrier_Sname;

            mpeCarrierViewpopup.Show();
        }
Пример #4
0
        protected void btnSave_Click1(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                CarrierEntity carrier = new CarrierEntity();
                carrier.M_Carrier_Slno  = Convert.ToInt32(carrieridEditpopup.Value);
                carrier.M_Carrier_Name  = txtcarriernameEditpopup.Text.Trim();
                carrier.M_Carrier_Sname = txtcarriershortnameEditpopup.Text.Trim();

                if (carrier.M_Carrier_Slno != 0)
                {
                    UpdateCarrier(carrier);
                }

                LoadData();
            }
        }
Пример #5
0
        public bool AddNewCarrier(CarrierEntity carrier)
        {
            String insertQuery = @"INSERT INTO [M_Carrier] ([M_Carrier_Name],[M_Carrier_Sname]) VALUES(@M_Carrier_Name, @M_Carrier_Sname)";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = insertQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Carrier_Name", carrier.M_Carrier_Name);
                cmd.Parameters.AddWithValue("@M_Carrier_Sname", carrier.M_Carrier_Sname);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                cmd.ExecuteNonQuery();

                return(true);
            }
        }
Пример #6
0
        public bool UpdateCarrier(CarrierEntity carrier)
        {
            String updateQuery = @"UPDATE [M_Carrier] SET [M_Carrier_Name] = @M_Carrier_Name ,[M_Carrier_Sname] = @M_Carrier_Sname Where[M_Carrier_Slno] = @M_Carrier_Slno";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = updateQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Carrier_Slno", carrier.M_Carrier_Slno);
                cmd.Parameters.AddWithValue("@M_Carrier_Name", carrier.M_Carrier_Name);
                cmd.Parameters.AddWithValue("@M_Carrier_Sname", carrier.M_Carrier_Sname);


                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                cmd.ExecuteNonQuery();

                return(true);
            }
        }