public string Lotselect(string s) { try { SqlDataReader rd = dw.Lotselect_2(s); int k = 0; if (rd.HasRows) { rd.Read(); // read first row if (rd["selectlot"] == DBNull.Value /*|| (int)rd["selectlot"] == 0*/) { k = 0; } else if ((int)rd["selectlot"] == 0) { k = 0; } else if ((int)rd["selectlot"] == 1) { k = 1; goto done; } else { k = 5; } } else { k = 0; } done: string str; if (k == 1) { str = "not Select as main lot"; } else if (k == 0) { dw.selectlot(s); str = "selected as main lot "; } else { return("Can't complete precedure"); } return(str); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } }