protected void signup_Click(object sender, EventArgs e) { main_class m = new main_class(); //check string check = string.Format("select * from professor where username = '******' ",Profesor_usrname.Text); DataTable dt = m.filldt(check); if (dt.Rows.Count != 0) { exists.Visible = true; } else { int id = m.get_maxid("professor"); string professor_register = string.Format("insert into professor (professor_Id,FName,Email,Contactno,Username,Password,approved,institute) values ({0},'{1}','{2}',{3},'{4}','{5}' , 'No' , '{6}') ", id, Profesor_name.Text, Profesor_email.Text, Profesor_no.Text, Profesor_usrname.Text, Profesor_passwrd.Text, institute.Text); m.insertvalues(professor_register); //dispose m.cn.Close(); m = null; Response.Redirect("Professor_login.aspx"); } }
protected void login_Click(object sender, EventArgs e) { main_class m = new main_class(); string get = string.Format("select * from student where username = '******' and password = '******' ", student_username.Text,student_password.Text); DataTable dt = m.filldt(get); m.cn.Close(); m = null; if (dt.Rows.Count != 0) { if (dt.Rows[0]["Approved"].ToString() != "Yes") { approval.Visible = true; } else { Session["Student_Username"] = student_username.Text; Response.Redirect("student_home.aspx"); } } else { wrong.Visible = true; } }
void Professor_Professor_EditProfile_LoadComplete(object sender, EventArgs e) { main_class m = new main_class(); string username = ""; try { username = Session["Professor_Username"].ToString();} catch (Exception ex) { Response.Redirect("Professor_login.aspx"); } string load_data = string.Format("select * from Professor where username = '******' ", username); DataTable dt = m.filldt(load_data); string get_dept = string.Format("select distinct department_name from department"); DataTable dt1 = m.filldt(get_dept); department.DataSource = dt1; department.DataBind(); first_name.Text = dt.Rows[0]["fname"].ToString(); Middle_name.Text = dt.Rows[0]["mname"].ToString(); last_name.Text = dt.Rows[0]["lname"].ToString(); mail_id.Text = dt.Rows[0]["email"].ToString(); img.ImageUrl = dt.Rows[0]["ProfilePic"].ToString(); contactno.Text = dt.Rows[0]["contactno"].ToString(); //high_school.Text = dt.Rows[0]["school"].ToString(); college.Text = dt.Rows[0]["INSTITUTE"].ToString(); gender.Text = dt.Rows[0]["gender"].ToString(); bdate_date.Text = dt.Rows[0]["bdate"].ToString(); enrollmentno.Text = dt.Rows[0]["Professor_Id"].ToString(); department.SelectedValue = dt.Rows[0]["department"].ToString(); m.cn.Close(); m = null; }
protected void LinkButton2_Click(object sender, EventArgs e) { try { string tp = new main_class().GetCompanyName(Convert.ToInt32(TextBox2.Text)); if (tp != "0") { Session["type"] = TextBox2.Text; Session["coname"] = tp; Session["idid"] = TextBox2.Text; string ur = "http://" + Request.Url.Authority; for (int i = 0; (i + 1) < Request.Url.Segments.Length; i++) { ur += Request.Url.Segments[i]; } string srf = ur; ScriptManager.RegisterClientScriptBlock(this, Page.GetType(), "j01", "window.open('frm_cars.aspx','_blank')", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "j02", "alert('یافت نشد');", true); } } catch (Exception __e) { string errmsg = __e.Message; errmsg = errmsg.Replace("'", " "); new main_class().execute_command("insert into tbl_errors(e_err,e_uri) values ('" + errmsg + "','" + Request.Url.AbsoluteUri + "')"); ScriptManager.RegisterStartupScript(this, this.GetType(), "j02", "alert('یافت نشد');", true); } }
protected void Page_Load(object sender, EventArgs e) { RadAjaxManager.GetCurrent(Page); try { if (Page.AppRelativeVirtualPath != "~/login.aspx") { string username = Request.Cookies["username"].Value.ToString(); string pass = Request.Cookies["password"].Value.ToString(); string ownerid = Request.Cookies["owner"].Value.ToString(); string userWeight = Request.Cookies["userWeight"].Value.ToString(); string useridfromDB = new main_class().Encode(((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString()); Session["owner"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString(); Session["OwnerID"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString(); Session["userWeight"] = userWeight; Session["username"] = username; Session["password"] = pass; } } catch (Exception __e) { Response.Redirect("login.aspx"); } }
void Student_View_attendance_LoadComplete(object sender, EventArgs e) { main_class m=new main_class(); //string student = Session["Student_Username"].ToString(); string student = ""; try { student = Session["Student_Username"].ToString(); } catch (Exception ex) { Response.Redirect("Student_login.aspx"); } int student_id = int.Parse(m.get_idfromusername("student",student).ToString()); string attn = string.Format("select * from attendence where student_id = {0} ORDER BY attendence_ID DESC ", student_id); DataTable dt = m.filldt(attn); attendence.DataSource = dt; attendence.DataBind(); int count = 0; for (int i = 0; i < attendence.Rows.Count; i++) { if (attendence.Rows[i].Cells[3].Text == "Present") { count++; } } int per = (count * 100) / attendence.Rows.Count ; percentage.Text = per + " %"; }
protected void Button1_Click(object sender, EventArgs e) { if (new main_class().is_user_available_by_username(TextBox23.Text) == false) { tbl_usersTableAdapter md = new tbl_usersTableAdapter(); md.InsertIntoUsers(TextBox23.Text, new main_class().Encode(TextBox19.Text), "", TextBox6.Text, TextBox15.Text, TextBox16.Text, TextBox17.Text, TextBox18.Text, TextBox20.Text, TextBox21.Text, TextBox22.Text); pnl_registration_complete.Visible = true; pnl_registration_form.Visible = false; pnl_registration_forget.Visible = false; main_class mc = new main_class(); string str = mc.get_value_from_setting("email_registration_body"); str = Regex.Replace(str,"000", mc.get_value_from_setting("pub_en_company_name")); str = Regex.Replace(str, "001", TextBox23.Text); str = Regex.Replace(str, "002", TextBox19.Text); str = Regex.Replace(str, "003", TextBox23.Text); str = Regex.Replace(str, "004", TextBox19.Text); str = Regex.Replace(str, "005", mc.get_value_from_setting("home_page_address")); str = Regex.Replace(str, "006", mc.get_value_from_setting("home_page_address")); str = Regex.Replace(str, "007", mc.get_value_from_setting("fa_address_of_company")); str = Regex.Replace(str, "008", mc.get_value_from_setting("en_address_of_company")); mc.send_email(TextBox18.Text, "Registration in " + mc.get_value_from_setting("pub_en_company_name"), str); } else { pnl_registration_complete.Visible = false; pnl_registration_form.Visible = false; pnl_registration_forget.Visible = true; } }
protected void LinkButton1_Click(object sender, EventArgs e) { Session["NewsShownType"] = ""; LinkButton lb = (sender as LinkButton); Label1.Text = lb.Text; Session["NewsType"] = lb.Text; Session["NewsIDGroup"] = lb.ToolTip; string form_name = new tbl_modulesTableAdapter().GetFormNameFromID(Convert.ToInt16(lb.ToolTip.ToString())); string username = "******"; string password = "******"; if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { username = Request.Cookies["username"].Value.ToString(); password = Request.Cookies["password"].Value.ToString(); } string ModelID = new main_class().Load_Control(form_name, username, password); int i = ModelID.IndexOf("frm_AccessDenied"); if (i == -1) { ods_NewsList.SelectParameters[0].DefaultValue = lb.ToolTip.ToString(); GridView1.DataBind(); } else { ods_NewsList.SelectParameters[0].DefaultValue = "-1"; GridView1.DataBind(); } Response.Redirect(Request.Url.PathAndQuery); }
protected void Upload_Image_Click(object sender, EventArgs e) { string User = Session["admin"].ToString(); if (User == null || User == string.Empty) { Response.Redirect("Admin_Login.aspx"); } else { string cat = "hello"; main_class m = new main_class(); //file upload code if (FileUpload1.HasFile) { string q = "/images/PhotoGallery/" + FileUpload1.PostedFile.FileName; FileUpload1.SaveAs(MapPath(q)); int max_id = m.get_maxid("PhotoGallery"); //Inserting in db string q1 = string.Format("insert into PhotoGallery values ({0},'{1}','{2}','{3}') ", max_id, q, cat, User); SqlCommand insertCommand = new SqlCommand(q1, m.cn); insertCommand.ExecuteNonQuery(); Response.Write("Image Uploaded"); } m.cn.Close(); m = null; } }
protected void fill_Click(object sender, EventArgs e) { string professor = Session["Professor_Username"].ToString(); main_class m = new main_class(); for (int i = 0; i < attendence.Rows.Count; i++) { string result = ""; RadioButtonList rb = attendence.Rows[i].Cells[4].FindControl("rblist") as RadioButtonList; if (rb.Items[0].Selected == true) { result = "Present"; } if (rb.Items[1].Selected == true) { result = "Absent"; } int max_id=m.get_maxid("attendence"); string ins_attn = string.Format("insert into attendence values ({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8}) ", max_id, attendence.Rows[i].Cells[0].Text, attendence.Rows[i].Cells[1].Text, attendence.Rows[i].Cells[2].Text, result, professor, date.Text.ToString(), subject.Text, attendence.Rows[i].Cells[3].Text); m.insertvalues(ins_attn); } }
protected void lb_signin_Click(object sender, EventArgs e) { string username = txt_login.Text; string password = txt_password.Text; password = new main_class().Encode(password); int rec_count = (int)new tbl_stockholdersTableAdapter().CheckIfUserAndPassValid(username, password); if (rec_count == 1) { pnl_login.Visible = false; pnl_StockManagerBody.Visible = true; foreach (DataRow dr in new tbl_stockholdersTableAdapter().GetDataByUserName(username).Rows) { txt_AccountNo.Text = dr["s_hesabno"].ToString(); txt_AccountNoe.Text = dr["s_bankaccounttype"].ToString(); txt_BankName.Text = dr["s_bankname"].ToString(); txt_CodeSaham.Text = dr["s_stockid"].ToString(); txt_MizanSaham.Text = dr["s_stockcount"].ToString(); txt_name.Text = dr["s_name"].ToString() + " " + dr["s_family"].ToString(); } Response.Cookies.Add(new HttpCookie("stock_username",username)); Response.Cookies.Add(new HttpCookie("stock_pass",password)); } else { txt_name.Text = "نام کاربری را اصلاح کنید"; txt_password.Text = ""; pnl_login.Visible = true; pnl_StockManagerBody.Visible = false; } Response.Redirect(Request.Url.PathAndQuery); }
public static void Main(String[] args) { main_class obj = new main_class(); obj.show_result(obj.check_prime(obj.read_number())); // waiting for user enter any key Console.ReadKey(); }
protected void LinkButton1_Click(object sender, EventArgs e) { string username = Request.Cookies["username"].Value; username = new main_class().Decode(username); int userID = (int)new tbl_usersTableAdapter().getUserType(username); new MainDataModuleTableAdapters.rbl_statics_okTableAdapter().Insert( Convert.ToInt32((sender as LinkButton).ToolTip), 3, userID); GridView1.DataBind(); }
public static void Main(String[] args) { main_class obj = new main_class(); try{ obj.menu_driven(); }catch (Exception e) { Console.WriteLine("main_class.Main :- {0}", e); } }
protected void approve_Click(object sender, EventArgs e) { object ID = ((Button)sender).CommandArgument; Response.Write(ID.ToString()); main_class m = new main_class(); string update = string.Format("update professor set approved = 'Yes' where Professor_Id= {0} ",ID); m.insertvalues(update); bind_profesor(); }
public void GenerateCellNo() { lst_CellNos.Items.Clear(); ArrayList al = new main_class().GenerateCellNoList(10, txt_static_cell_no_part.Text, Convert.ToInt32(txt_count.Text)); for (int i = 0; i < al.Count; i++) { lst_CellNos.Items.Add(al[i].ToString()); } Session["chkSentRnd"] = lst_CellNos; }
void Bind_students() { main_class m = new main_class(); string get_students = string.Format("select * from student where approved = 'No' "); DataTable dt = m.filldt(get_students); students.DataSource = dt; students.DataBind(); m.cn.Close(); }
protected void view_Click(object sender, EventArgs e) { main_class m = new main_class(); string i = ((Button)sender).CommandArgument.ToString(); string get = string.Format("select * from docs where docs_id = '{0}' ",i); DataTable dt = m.filldt(get); string outputPdfFile = dt.Rows[0]["doc_path"].ToString(); Response.ContentType = "Application/pdf"; Response.TransmitFile(outputPdfFile); }
protected void add_Click(object sender, EventArgs e) { string admin= Session["User"].ToString(); main_class m = new main_class(); int max_id = m.get_maxid("Department"); string ins = string.Format("insert into department values ({0},'{1}','{2}') ",max_id,department.Text,admin); m.insertvalues(ins); bind_files(); }
void Professor_Professor_Home_LoadComplete(object sender, EventArgs e) { main_class m = new main_class(); string username = ""; try { username = Session["Professor_Username"].ToString(); } catch (Exception ex) { Response.Redirect("Professor_Login.aspx"); } string load_data=string.Format("select * from Professor where username = '******' ", username); DataTable dt=m.filldt(load_data); first_name.Text = dt.Rows[0]["fname"].ToString(); Middle_name.Text = dt.Rows[0]["mname"].ToString(); last_name.Text = dt.Rows[0]["lname"].ToString(); mail_id.Text = dt.Rows[0]["email"].ToString(); img.ImageUrl = dt.Rows[0]["ProfilePic"].ToString(); contactno.Text = dt.Rows[0]["contactno"].ToString(); //high_school.Text = dt.Rows[0]["school"].ToString(); college.Text = dt.Rows[0]["institute"].ToString(); try { if (int.Parse(dt.Rows[0]["gender"].ToString()) == 0) { gender.Text = "Male"; } else if (int.Parse(dt.Rows[0]["gender"].ToString()) == 1) { gender.Text = "Female"; } else { gender.Text = dt.Rows[0]["gender"].ToString(); } } catch (Exception ec) { gender.Text = "Update Gender"; } bdate_date.Text = dt.Rows[0]["bdate"].ToString(); enrollmentno.Text = dt.Rows[0]["Professor_id"].ToString(); department.Text=dt.Rows[0]["department"].ToString(); //bind subjects string get_sub = string.Format("select * from professor_subjects where Professor_username = '******' ",username); DataTable dt_sub = m.filldt(get_sub); Professor_Subjects.DataSource = dt_sub; Professor_Subjects.DataBind(); m.cn.Close(); m = null; }
protected void save_Click(object sender, EventArgs e) { main_class m = new main_class(); string img_path = ""; //Image Upload Code if (FileUpload1.HasFile) { try { System.IO.File.Delete(MapPath(img.ImageUrl)); } catch { } img_path = "/images/ProfilePic_Student/" + FileUpload1.FileName; FileUpload1.SaveAs(MapPath(img_path)); } else { img_path = img.ImageUrl; } // string username = Session["Student_Username"].ToString(); int id = m.get_idfromusername("student",username); string update = string.Format("update student set fname='{0}',"+ "mname='{1}',"+ "lname='{2}',"+ "email='{3}',"+ "contactno={4},"+ "profilepic='{5}',"+ "school='{6}',"+ "college='{7}',"+ "bdate='{8}',"+ "gender='{9}',"+ "enrollno='{10}',"+ "department = '{11}' where student_id = {12}", first_name.Text, Middle_name.Text, last_name.Text, mail_id.Text, contactno.Text, img_path, high_school.Text, college.Text, bdate_date.Text, gender.Text, enrollmentno.Text, department.Text, id ); m.insertvalues(update); m = null; }
protected void dept_TextChanged(object sender, EventArgs e) { main_class m = new main_class(); string get_students = string.Format("select * from student where department = '{0}' ", dept.SelectedValue.ToString()); DataTable students = m.filldt(get_students); attendence.DataSource = students; attendence.DataBind(); m.cn.Close(); m = null; }
public void bind_files() { main_class m = new main_class(); string admin = Session["admin"].ToString(); string get_docs = string.Format("select * from department where admin_name = '{0}' ", admin); DataTable dt = m.filldt(get_docs); dept.DataSource = dt; dept.DataBind(); }
protected void searchbtn_Click(object sender, EventArgs e) { main_class m = new main_class(); string get_docs = string.Format("SELECT * FROM docs WHERE doc_title LIKE '%{0}%' ", search.Text ); DataTable dt = m.filldt(get_docs); docs.DataSource = dt; docs.DataBind(); m.cn.Close(); m = null; }
protected void Button1_Click(object sender, EventArgs e) { main_class mc = new main_class(); // vvvvv for editing group permission if (GridView2.Visible == true) { for (int i = 0; i < GridView2.Rows.Count; i++) { int GroupID = (int)GridView2.DataKeys[i][0]; CheckBox cb = (CheckBox)GridView2.Rows[i].FindControl("chk_select"); if (cb.Checked) { for (int y = 0; y < GridView3.Rows.Count; y++) { int ModuleID = (int)GridView3.DataKeys[y][0]; ListItem li = (ListItem)(GridView3.Rows[y].FindControl("ListBox1") as ListBox).SelectedItem; if (li != null) { mc.execute_command(string.Format("delete from tbl_groups_permission where gd_tbl_groups_link={0} and gd_module_link={1}", GroupID.ToString(), ModuleID.ToString())); mc.execute_command(string.Format("insert into tbl_groups_permission (gd_tbl_groups_link,gd_module_link,gd_blocked) values ({0},{1},{2})", GroupID.ToString(), ModuleID.ToString(), li.Value.ToString())); } } } } } // vvvvv for editing user permission if (GridView1.Visible == true) { for (int i = 0; i < GridView1.Rows.Count; i++) { int UserID = (int)GridView1.DataKeys[i][0]; CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("chk_select"); if (cb.Checked) { for (int y = 0; y < GridView3.Rows.Count; y++) { int ModuleID = (int)GridView3.DataKeys[y][0]; ListItem li = (ListItem)(GridView3.Rows[y].FindControl("ListBox1") as ListBox).SelectedItem; if (li != null) { mc.execute_command(string.Format("delete from tbl_users_permission where up_user_link={0} and up_module_link={1}", UserID.ToString(), ModuleID.ToString())); mc.execute_command(string.Format("insert into tbl_users_permission (up_user_link,up_module_link,up_blocked) values ({0},{1},{2})", UserID.ToString(), ModuleID.ToString(), li.Value.ToString())); } } } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["owner"] == null) { Session["modulename"] = Request.Url.PathAndQuery; Response.Redirect("login.aspx"); } else { try { string username = Request.Cookies["username"].Value.ToString(); string pass = Request.Cookies["password"].Value.ToString(); string ownerid = Request.Cookies["owner"].Value.ToString(); string userWeight = Request.Cookies["userWeight"].Value.ToString(); string useridfromDB = new main_class().Encode(((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString()); if (ownerid != useridfromDB) { Session["modulename"] = Request.Url.PathAndQuery; Response.Redirect("login.aspx"); } else { Session["owner"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString(); Session["OwnerID"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString(); Session["userWeight"] = new main_class().Decode(userWeight); Session["username"] = username; Session["password"] = pass; } } catch (Exception __e) { Response.Redirect("login.aspx"); } } if (!IsPostBack) { Literal1.Text = new tbl_sms_recieved_formattedTableAdapter().GetUnreadSMSCount(Convert.ToInt32(Session["owner"].ToString())).Value.ToString(); lbl_OwnerName.Text = new MainDataModuleTableAdapters.tbl_ownerTableAdapter().GetOwnerNameFromOID(Convert.ToInt32(Session["owner"].ToString())); lbl_today.Text = new main_class().Convert_to_Shamsi(DateTime.Now); } lbl_current_value.Text = new MainDataModuleTableAdapters.tbl_sms_billingTableAdapter().GetLastCredit(Convert.ToInt32(Session["owner"].ToString()) ).ToString(); }
void Student_student_home_LoadComplete(object sender, EventArgs e) { main_class m = new main_class(); string username = ""; try { username = Session["Student_Username"].ToString(); } catch (Exception ex) { Response.Redirect("Student_login.aspx"); } string load_data = string.Format("select * from Student where username = '******' ", username); DataTable dt = m.filldt(load_data); first_name.Text = dt.Rows[0]["fname"].ToString(); Middle_name.Text = dt.Rows[0]["mname"].ToString(); last_name.Text = dt.Rows[0]["lname"].ToString(); mail_id.Text = dt.Rows[0]["email"].ToString(); img.ImageUrl = dt.Rows[0]["ProfilePic"].ToString(); contactno.Text = dt.Rows[0]["contactno"].ToString(); //high_school.Text = dt.Rows[0]["school"].ToString(); college.Text = dt.Rows[0]["college"].ToString(); department.Text=dt.Rows[0]["department"].ToString(); try { if (int.Parse(dt.Rows[0]["gender"].ToString()) == 0) { gender.Text = "Male"; } else if (int.Parse(dt.Rows[0]["gender"].ToString()) == 1) { gender.Text = "Female"; } else { gender.Text = dt.Rows[0]["gender"].ToString(); } } catch (Exception) { } bdate.Text = dt.Rows[0]["bdate"].ToString(); enrollmentno.Text = dt.Rows[0]["EnrollNo"].ToString(); m.cn.Close(); m = null; }
void Admin_PhotoGallery_LoadComplete(object sender, EventArgs e) { main_class m = new main_class(); DataTable dt = m.displayImages(); //dt.Columns.Add("Image_toshare"); //for (int i = 0; i < dt.Rows.Count; i++) //{ // dt.Rows[i]["image_toshare"] = Path.GetFileName(dt.Rows[i]["image_path"].ToString()); ; //} Image_Results.DataSource = dt; Image_Results.DataBind(); }
void bind_profesor() { main_class m = new main_class(); //string get_students = string.Format("select * from professor where approved = 'No' "); string get_students = string.Format("select * from professor where approved = 'No' "); DataTable dt = m.filldt(get_students); professor.DataSource = dt; professor.DataBind(); m.cn.Close(); m = null; }
protected void docs_RowDeleting(object sender, GridViewDeleteEventArgs e) { main_class m = new main_class(); string i = dept.Rows[e.RowIndex].Cells[0].Text; string deleterow = string.Format("delete from department where Department_Id = {0}", i); SqlCommand delete_cmd = new SqlCommand(deleterow, m.cn); delete_cmd.ExecuteNonQuery(); bind_files(); m.cn.Close(); i = null; delete_cmd.Dispose(); }
protected void search_professor_TextChanged(object sender, EventArgs e) { if (IsPostBack) { main_class m = new main_class(); string search_pro = string.Format("select * from Professor where Fname LIKE '%{0}%' OR Lname LIKE '%{0}%' ", search_professor.Text); DataTable dt = m.filldt(search_pro); professor.DataSource = dt; professor.DataBind(); m.cn.Close(); m = null; } }
protected void download_Click(object sender, EventArgs e) { main_class m = new main_class(); string i = ((Button)sender).CommandArgument.ToString(); string d = string.Format("select * from docs where docs_id = {0}", i); DataTable dt = m.filldt(d); string q = dt.Rows[0]["doc_path"].ToString(); string filePath = q; Response.ContentType = ContentType; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath)); Response.WriteFile(filePath); Response.End(); m.cn.Close(); }