jbisono 51 Posting Pro in Training

You can do this to display an alert.
ScriptManager.RegisterStartupScript(sender, sender.GetType(), "alert", "alert('Product Added Successfully');", true);

jbisono 51 Posting Pro in Training

In your webmethod you have this line
DropDownList ddl = (DropDownList)sender;
"sender" in this case is a button and you are trying to convert a button to dropdownlist, which that won't happen.

Change the "object sender" parameter in your function to "string pcategory" or whatever you want it to call it, and use that, you are already sending a string so there is no need to do what you are trying to do.

jbisono 51 Posting Pro in Training
<asp:DropDownList ID="DropDownList2" runat="server" style="margin-left: 75px" 
   Width="131px" DataSourceID="SqlDataSource1"    DataTextField="product_category" 
   DataValueField="product_category" AutoPostBack="True">
   <asp:ListItem>casting</asp:ListItem>
</asp:DropDownList>

Like the error says you, there is no prod_category and your datasource, so you have to change it for the real name which is product_category base on your select statement.

jbisono 51 Posting Pro in Training

First you create your class, within your class you put your properties and methods so a class for the student will look like this.

public class Student 
{
   private string studentId;
   public string StudentId
   {
      get { return studentId; }
      set { studentId = value; }
   }
   private string courseId;
   public string CourseId
   {
      get { return courseId; }
      set { courseId = value; }
   }
   public void Registration()
   {
      Console.WriteLine(this.studentId + " - " + this.courseId);
   }
}

and then and your main function you can instantiate an object student like this

Student student = new Student();
student.StudentId = "1";
student.CourseId = "2";
student.Registration();
ddanbe commented: Well explained +15
jbisono 51 Posting Pro in Training

Can you post your GridView Control Structure and the code you are using to bind the Grid?

jbisono 51 Posting Pro in Training

If you dont want to filter out just the items that does not have a -U then you can do this. I'm assuming that the '-U' is always at the end.

SELECT CASE WHEN SUBSTRING(ItemNumber, LEN(ItemNumber) - 1, 2) = '-U' THEN ItemNumber ELSE ItemNumber + '-U' END AS MyNewItemNumber
From YOURTABLE
jbisono 51 Posting Pro in Training

to answer your question you have to concatenate the textbox like this

description.Text += ndate + Environment.NewLine + dnotes;
jbisono 51 Posting Pro in Training

So im guessing that you have a LinkButton or something like that to trigger the rowcommand event.

I think i have used this before and it works.

int rowIndex = Convert.toInt32(e.CommandArgument);

if that one above dont work you can try this lets say again that the rowcommand is trigger by a linkbutton you will do this.

GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int rowIndex = row.RowIndex;
jbisono 51 Posting Pro in Training

Try to use the property enabled instead of the ReadOnly to see what happens, i dont play too much with windows forms but in asp.net that would work.

jbisono 51 Posting Pro in Training

Hi
i believe you can do this.

DataView MyDataView = MyDataSet.Tables[0].DefaultView;

MyDataView.RowFilter = "IdCardNumber = "+Convert.ToInt32(textbox1.Text)+"";
MyDataGrid.DataSource = MyDataView;
MyDataGrid.DataBind();
jbisono 51 Posting Pro in Training

Ok i wanted to make sure we are in the same page :).

i did something similar but with the customer order process, anyway what about if you create another table with the Purchase_order, Line_No or Part_No (dont know how your table are set up) but basically for each purchase order -> part No you can have multiple serial No. then you will be able to enter as many serial no as you order qty.

this is how you can make it easier for the person who is entering the data, if you order 10 pieces and the manufacturer give this no as serial no sn100-001 after the dash is an incremental No. up to qty order then you can do some programming to generate 10 serial No. because is not funny have a order qty of 100 parts and entering that manually you have to find a convention how you can generate those serials no.

I have seen people using an excel sheet also to import that to the tables.

debasisdas commented: good suggestion. +9
jbisono 51 Posting Pro in Training

There are few thing that i should revise here.
1. when you make a instance of the SqlCommand with the Name of the stored procedure and the SqlConnection you do not have to set the CommandText property of the SqlCommand, you can delete that line.

2. I see you execute the method Read() of the DataReader with out the while loop, you dont have to do that, just do this while(Reader.Read()){code here}

3. When you finish reading thru the DataReader you have to execute the method Close of the DataReader.

first fix these things try to run and let me know what do you get.

jbisono 51 Posting Pro in Training

About the first question when you say by the manufacturer sounds like you are acquiring the product thru a purchase order right? if that is true then i will save the serial no in the purchase order line item. Note: what happened if you are ordering 10 pieces for the same product? does that means you have 10 different serial no's?

for the second question once you have your purchase order now you have your products with the serial no too.

let me know if i help you a little bit with this, maybe you can explain better.

jbisono 51 Posting Pro in Training

You can try this, is the first thing comes to my mind, in your Page_Load Method do this.

foreach(ListItem li in RadioButtonList1.Items)
{
   li.Attributes.Add("onClick", "CheckChange('" + li.Text + "','" + li.Value + "')");
}

Then just create a javascript function called CheckChange, li.text and li.value are parameters

Hope that helps!!!

jbisono 51 Posting Pro in Training

Try a Inner Join like this.

SELECT TABLE1.FIELD1, TABLE1.FIELD2
FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.FIELD3 = TABLE2.FIELD3
WHERE TABLE2.FIELD4 BETWEEN 'A1' AND 'A50'
jbisono 51 Posting Pro in Training

I dont know if this might help you too, i sometimes has problem using dropdownlist.selectedValue; instead i use DropDownList.SelectedItem.Value, the last one seems to work right. as far as i know they both should do the same, but why one is working for me and the other one not, dont know yet.

regards

jbisono 51 Posting Pro in Training

Check the selectCommand in sqldatasource id "jobSqlDS" add "Distinct" in the select statement and give it a try.

jbisono 51 Posting Pro in Training

try two things.
first: try to make the id parameter in the same manner as the others.
second: instead of using the ExecuteReader method use ExecuteNonQuery method. that returns the number of rows affected by the query.

regards.

jbisono 51 Posting Pro in Training

try to use the SingeOrDefault method. like

Dim owing = (From accounts In db.Accounts Where accounts.CustNumber Is current Select accounts.AmountOwing).SingeOrDefault()
jbisono 51 Posting Pro in Training

well remember that the avg function it will find the avg by rows because how many rows its hard to know, but if you want the avg for multiple columns and a specific row, its more straightforward because you know how many columns are so you will end up with something like.

SELECT NAME, ((SCORE1 + SCORE2 + SCORE3) / 3) AS AVERAGE
FROM TABLE1
jbisono 51 Posting Pro in Training

The thing is that the AVG Function is an aggregate one, so that usually means that you have to group by so your statement will end something like this.

SELECT NAME, AVG(SCORE1 + SCORE2 + SCORE3) AS AVERAGE
FROM TABLE1
GROUP BY NAME
jbisono 51 Posting Pro in Training

Do you mean if num is decimal? in that case you can overload the function.

jbisono 51 Posting Pro in Training

Try to calculate that at the database level, and return the total with your result. your statement should looks like

SELECT NAME, SCORE1, SCORE2, SCORE3, SCORE1 + SCORE2 + SCORE3 AS TOTAL
FROM YOURTABLE
Lusiphur commented: Excellent Recommendation :) +1
jbisono 51 Posting Pro in Training

That looks good. Just a few things to check out.

1 - The Connection String is recommended to keep it in one place, like the web.config if you are in web development or some ini file.

2 - The ExecuteNonQuery() method is a really common use one. So if you can create a separate class and create a function to receive the string query and the connection(the last parameter only need it if you deal with different database), return an integer. this help to avoid repeating code.

3 - this is just a recommendation, something different, check "LINQ" .

jbisono 51 Posting Pro in Training

well men i do not want make you feel bad either, i know is not easy at the beginning thats why we have to read a lot. and maybe linq is not the best option to start but with reading a little bit, i bet you anyone can get somereal work done, and almost all the tutorial explain everything where thins comes from. anyway here some links that can help you.

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx
http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

the northwind database you can download it from microsoft website.

nick.crane commented: Nice LINQ links, thanks +1
jbisono 51 Posting Pro in Training

Well i think I am with nick.crane you should create like a book store yourself put some table that then you can query by category, author, language, country etc. and start playing making updates etc. and then come up with more specific questions. some people like to see some real productivity soon, if that is your case i recommend you using LINQ. there is some tool that generate classes for you base on your database, and you can get some real code fast and good.

but it is always nice to see how everything works in details.

jbisono 51 Posting Pro in Training

The first one.

jbisono 51 Posting Pro in Training

You have two options:
first: you can create a extra column in your query to return true or false if your part No start with your criteria, then bound that to the checkboxcolumn.

Second: you have to use the DataGrid.OnItemDataBound Method here is an example then with in that method you will have to compare your format with the part being bound in the datagrid and then check or not your checkbox column.

jbisono 51 Posting Pro in Training

DateTime.Today.ToShortDateString();

Use ToShortDateString() Method.

jbisono 51 Posting Pro in Training

look i can give you a loop for that right now, but let me ask you this, why if you want to retrieve all the record where the level goes from 1 to 8, why dont you say and your stored procedure "where level between 1 and 8" and that case you make just one request to the server and get all the record you need.

fadi-ft commented: good man +1
jbisono 51 Posting Pro in Training

I still dont get what is your problem, but it sounds like you need a recursive function or a loop somewhere. you have to explain a little bit more.

jbisono 51 Posting Pro in Training

Line 39 should be like this
SqlCommand cmd1 = new SqlCommand("usp_selectnodes", conn1);

jbisono 51 Posting Pro in Training
string find = "AAD";
            string result = "<table><tr><td>AAD</td><td>35%</td></tr><tr><td>hola</td><td>40%</td></tr></table>";
            string[] arrLines = Regex.Split(result, @"<tr.*?>",RegexOptions.IgnoreCase);

            foreach (string strLine in arrLines)
            {
                string[] strCol = Regex.Split(strLine, @"<td.*?>",RegexOptions.IgnoreCase);
                for (int i = 0; i < strCol.Length; i+=1)
                {
                    string test = Regex.Replace(strCol[i], @"<[^>]*>", "");
                    if (test == find)
                    {
                        String Rate += Regex.Replace(strCol[i + 1], @"<[^>]*>", "");
                    }
                }
            }

this is not the best approach but it will do the work. the ouput is String Rate = 35%.

regards

jbisono 51 Posting Pro in Training

To get the selected item from a dropdownlist you do this.

String selectedItem = DropDownList1.SelectedItem.Value;

now if you want to save that value right after the user change selection you have to set autopostback property in the dropdownlist to true and under the OnselectedIndexChanged event create your procedure to save that value in the database.

regards

jbisono 51 Posting Pro in Training

I guess you only need two tables to accomplish this a "PERSON" table which hold all general information. and a "friend" table contains two fields both pimary keys, "ID_PERSON" and "ID_PERSON_FRIEND" in this case to get the person's friend should be very straightforward

SELECT *
FROM         PERSON INNER JOIN
                      FRIEND ON FRIEND.ID_PERSON = PERSON.USER_ID INNER JOIN
                      PERSON AS PERSON_1 ON FRIEND.ID_PERSON_FRIEND = PERSON_1.USER_ID
WHERE     (PERSON.USER_ID = 1)

the above statement will give all friends that belong to the user_id = 1 in the same way you can get the friends of the user_id = 1's friends. let me know if you have any trouble doing that.

regards

jbisono 51 Posting Pro in Training

This is from mind, but i think you can do this.

for (int i = 0; i < e.RowCount; i++)
{
      DataGridViewRow row = dgvOrders.Rows[e.RowIndex + i];
      if (row.Cells["printedDataGridViewTextBoxColumn"].Value != DBNull.Value)
      {
           row.Cells["Printed"].Value = imlIcons.Images["Printed"];
      }
      else
      {
           row.Cells["Printed"].Value = imlIcons.Images["blank"];
      }
}

Try something like that.

jbisono 51 Posting Pro in Training

Can you show what have you done so far?

jbisono 51 Posting Pro in Training

Oh i thought the running code in the windows schedule task was separately from the real program. Got it.

jbisono 51 Posting Pro in Training

I like your idea apegram!!!. the only thing is that I will exclude the date check since you can schedule windows to run daily in a specific time, i do not see the need to make date check.

jbisono 51 Posting Pro in Training

there are two things i can think of first

SELECT     DATEPART(Month, DATE) AS month, DATENAME(month, DATE) AS Name, avg(NetAmount) as AverageCustomerBill from salesmaster 
GROUP BY DATEPART(Month, DATE), DATENAME(month, DATE)
ORDER BY DATEPART(Month, DATE)

the other one

SELECT     CASE DATEPART(Month, DATE) 
                      WHEN 1 THEN 'January' WHEN 2 THEN 'February' WHEN 3 THEN 'March' WHEN 4 THEN 'April' WHEN 5 THEN 'May' WHEN 6 THEN 'June' WHEN 7 THEN
                       'July' WHEN 8 THEN 'August' WHEN 9 THEN 'September' WHEN 10 THEN 'October' WHEN 11 THEN 'November' ELSE 'December' END AS month, 
                      avg(NetAmount) as AverageCustomerBill from salesmaster 
GROUP BY DATEPART(Month, DATE)
ORDER BY DATEPART(Month, DATE)

regards

jbisono 51 Posting Pro in Training

Uhmmm, Thats wierd in my case it always pick it up automatically anyway, if you pay an external hosting you should contact their support, in the other hand if you are managing your own server then you have to find something to make a default content, for example in IIS its called Enable Default Content Page.

jbisono 51 Posting Pro in Training

Try replacing the left outer join with this
"LEFT OUTER JOIN Sedula ON Sedula.DocID = Document.DocNo" if that does not work I think you have to go over the design again, maybe if you explain a little bit what is the relation between these three tables i can help you finding any design problem.

jbisono 51 Posting Pro in Training

Then you cannot reference the sedula table thru the clearance table, just make the left outer join with document table. that should do it.

jbisono 51 Posting Pro in Training

Ok. Glad to know.

jbisono 51 Posting Pro in Training
SELECT *
      FROM DOCUMENT INNER JOIN
      CLEARANCE ON CLEARANCE.DOC_ID = DOCUMENT.DocNo LEFT OUTER JOIN
      SEDULA ON SEDULA.DOC_ID = CLEARANCE.DOC_ID INNER JOIN PERSON ON PERSON.PersonID = DOCUMENT.PesonID INNER JOIN
OFFICER ON OFFICER.OfficerID = DOCUMENT.OfficerID

notice that in order to get information from person in officer table you have to make the links.

jbisono 51 Posting Pro in Training

Ok.

SELECT *
FROM DOCUMENT INNER JOIN
CLEARANCE ON CLEARANCE.DOC_ID = DOCUMENT.DocNo LEFT OUTER JOIN
SEDULA ON SEDULA.DOC_ID = CLEARANCE.DOC_ID

Try that.

jbisono 51 Posting Pro in Training

When you say document>certificate what exactly is certificate for you here, because i do not see any certificate table?

jbisono 51 Posting Pro in Training

I do not know if i got you right, anyway you said that a clearance may have a tax certificate sounds to me that you cannot make direct reference between the tax certificate and document but thru clearance table. if this is the case you will have something like this.

SELECT * 
FROM DOCUMENT INNER JOIN
CLEARANCE ON CLEARANCE.DOCUMENT_ID = DOCUMENT.ID LEFT OUTER JOIN TAX_CERTIFICATE ON TAX_CERTIFICATE.ID_CLEARANCE = CLEARANCE.ID

I may be wrong but you can show a little bit more of your table structure to give a more accurate answer.

regards

jbisono 51 Posting Pro in Training

above this line GridView1.DataSource = ds you are missing this one adp.Fill(ds)

jbisono 51 Posting Pro in Training

OK this is what you have to do. lets say i have this datagrid with this linkbutton it does not matter just replace the linkbutton for regular button

Properties to take a look, CommandName and OnRowCommand

<asp:GridView ID="gvTools" runat="server" OnRowCommand="GetDetails" AutoGenerateColumns="false">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkView" runat="server" Text="View" CommandName="View"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

then and the background you have a function like this.

protected void GetDetails(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "View")
            {
                GridViewRow selectedRow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
//Just change the number for the cell you want.
                String variable = selectedRow.Cells[4].Text;
}
}

I hope that helps!!!.