void NewBusinessID() { ConClass obj = new ConClass(); try { SqlDataReader rd = obj.Selectdr("select isnull(max(ID)+1,1) from business"); while (rd.Read()) { using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString)) { sqlConnection.Open(); string insert = @"if not exists(select businessid from businessindex where businessID=@businessID) insert into businessIndex(businessID) values(@BusinessID) else insert into businessIndex(businessID) values(@BusinessID+1) "; using (SqlCommand sqlCommand = new SqlCommand(insert, sqlConnection)) { sqlCommand.Parameters.Add("@BusinessID", SqlDbType.NVarChar).Value = rd[0].ToString(); sqlCommand.ExecuteNonQuery(); } } } rd.Close(); SqlDataReader rd1 = obj.Selectdr("select isnull(max(businessID),1) from businessindex"); while (rd1.Read()) { Session["BusinessID"] = rd1[0].ToString(); } rd1.Close(); } catch (Exception) { throw; } }
string ReturnProvince(int ID) { string province = ""; try { SqlDataReader rd = obj.Selectdr("Select Name_Local as Name from zProvince where iD=" + ID); while (rd.Read()) { province = rd.GetValue(0).ToString(); } rd.Close(); } catch (Exception) { } return(province); }
bool IsPaid(string ID) { bool returnVal = false; using (ConClass obj = new ConClass()) { //System.Windows.Forms.MessageBox.Show(GetFilter()); SqlDataReader rd = obj.Selectdr(@"select ID from payment where ID=" + ID + " and YearID=substring(dbo.ToPersianDate(getdate()),1,4) and paymentStatusID=2"); if (rd.HasRows) { returnVal = true; } return(returnVal); } }