نمایش نتایج 1 تا 4 از 4

نام تاپیک: عدم خطا ولی کار نکردن کد

  1. #1
    کاربر دائمی آواتار saba664
    تاریخ عضویت
    شهریور 1396
    محل زندگی
    کرمانشاه
    سن
    37
    پست
    147

    عدم خطا ولی کار نکردن کد

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace finaldoctor2
    {
    public partial class Flogin : Form
    {
    public Flogin()
    {
    InitializeComponent();
    }
    LoginLogoutHandller LO = new LoginLogoutHandller();
    ManegerHandller MH = new ManegerHandller();
    ClerkHandller CH = new ClerkHandller ();
    LoginLogout L;

    private void login_Load(object sender, EventArgs e)
    {
    txtname.Enabled = false;
    txtpass.Enabled = false;
    }

    private void radioButton1_CheckedChanged(object sender, EventArgs e)
    {
    txtname.Enabled = true;
    txtpass.Enabled = true;
    }

    private void button1_Click(object sender, EventArgs e)
    {
    //Fmainf m = new Fmainf();
    // this.Hide();
    // m.Show();


    if (txtpass.Text != "" && txtname.Text != "")
    {
    if (radioButton1.Checked)
    {

    if (LO.loginManager(txtname.Text, txtpass.Text))
    {
    Initializer.Managerid = MH.Getid(txtname.Text, txtpass.Text);
    Initializer.Clerkid = 0;
    L = new LoginLogout(Initializer.shelltime() + " , " + DateTime.Now.ToShortTimeString(), "نامعلوم", Initializer.Clerkid , Initializer.Managerid );
    LO.RecordTraffic(L);
    //MessageBox.Show(id.ToString());
    Fmainf f = new finaldoctor2.Fmainf();
    this.Hide();
    f.ShowDialog();
    }
    else
    MessageBox.Show("نام کاربری یا رمز عبور در سیستم تعریف نشده است", "توجه ", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);


    }
    else if (radioButton2.Checked)
    {
    if (LO.loginClerk (txtname.Text, txtpass.Text))
    {
    Initializer.Clerkid = CH.Getid(txtname.Text, txtpass.Text);
    Initializer.Managerid = 0;
    L = new LoginLogout(Initializer.shelltime() + " , " + DateTime.Now.ToShortTimeString(), "نامعلوم", Initializer.Clerkid , Initializer.Managerid );
    LO.RecordTraffic(L);
    //int id = CH.GetId(txtUserName.Text, txtPass.Text);
    //MessageBox.Show(id.ToString());
    Fclerk f = new finaldoctor2.Fclerk();
    this.Hide();
    f.ShowDialog();
    }
    else
    MessageBox.Show("نام کاربری یا رمز عبور در سیستم تعریف نشده است", "توجه ", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

    }
    else
    MessageBox.Show("لطفا یکی از آیتم های مدیر یا صندوق دار را انتخاب کنید", "توجه ", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
    }
    else
    MessageBox.Show("رمز عبور یا نام کاربری را وارد کنید ");




    }

    private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {
    txtname.Enabled = true;
    txtpass.Enabled = true;
    }

    private void button2_Click(object sender, EventArgs e)
    {
    txtname.Text = "";
    txtpass.Text = "";
    }

    private void button3_Click(object sender, EventArgs e)
    {
    DialogResult dialog = MessageBox.Show("آیا مطمئن هستید؟", "خروج", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
    if (dialog == DialogResult.Yes)
    {
    Application.Exit();
    }
    }
    }
    }





    این کد منه

    و کلاس هام هم به ترتیب

    کلاس یوزر

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace finaldoctor2
    {
    public class User
    {
    protected string name;
    public string Name
    {
    get { return name; }
    set { name = value; }
    }
    protected string family;
    public string Family
    {
    get { return family; }
    set { family = value; }
    }
    protected string mobile;
    public string Mobile
    {
    get { return mobile; }
    set { mobile = value; }
    }
    protected string telwork;
    public string Telwork
    {
    get { return telwork; }
    set { telwork = value; }
    }
    protected string address;
    public string Address
    {
    get { return address; }
    set { address = value; }
    }
    protected string dateinsert;
    public string Dateinsert
    {
    get { return dateinsert ; }
    set { dateinsert = value; }
    }
    protected string nezam;
    public string Nezam
    {
    get { return nezam; }
    set { nezam = value; }
    }
    protected string code;
    public string Code
    {
    get { return code ; }
    set { code = value; }
    }
    protected string father;
    public string Father
    {
    get { return father ; }
    set { father = value; }
    }
    protected Boolean jenseyat;
    public Boolean Jenseyat
    {
    get { return jenseyat ; }
    set { jenseyat = value; }
    }
    protected string country;
    public string Country
    {
    get { return country ; }
    set { country = value; }
    }
    protected string shahrestan;
    public string Shahrestan
    {
    get { return shahrestan ; }
    set { shahrestan = value; }
    }
    protected string reshteh;
    public string Reshteh
    {
    get { return reshteh; }
    set { reshteh = value; }
    }
    protected Boolean madarak;
    public Boolean Madarak
    {
    get { return madarak ; }
    set { madarak = value; }
    }
    protected string vemployment;
    public string Vemployment
    {
    get { return vemployment; }
    set { vemployment = value; }
    }
    protected string khed1;
    public string Khed1
    {
    get { return khed1 ; }
    set { khed1 = value; }
    }
    protected string khed2;
    public string Khed2
    {
    get { return khed2 ; }
    set {khed2 = value; }
    }
    protected string khed3;
    public string Khed3
    {
    get { return khed3 ; }
    set { khed3 = value; }
    }
    protected string khed4;
    public string Khed4
    {
    get { return khed4 ; }
    set { khed4 = value; }
    }
    protected Boolean heat;
    public Boolean Heat
    {
    get { return heat ; }
    set { heat = value; }
    }
    protected Boolean matab;
    public Boolean Matab
    {
    get { return matab ; }
    set { matab = value; }
    }
    protected Boolean parvaneh;
    public Boolean Parvaneh
    {
    get { return parvaneh ; }
    set { parvaneh = value; }
    }
    protected Boolean vazeat;
    public Boolean Vazeat
    {
    get { return vazeat ; }
    set { vazeat = value; }
    }
    protected string mmt;
    public string Mmt
    {
    get { return mmt ; }
    set { mmt = value; }
    }
    protected byte photo;
    public byte Photo
    {
    get { return photo ; }
    set { photo = value; }
    }
    }
    }

  2. #2
    کاربر دائمی آواتار saba664
    تاریخ عضویت
    شهریور 1396
    محل زندگی
    کرمانشاه
    سن
    37
    پست
    147

    نقل قول: عدم خطا ولی کار نکردن کد

    کلاس دیتابیس

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SqlClient;
    using System.Data.Common;

    namespace finaldoctor2
    {
    public class DataBase
    {

    public SqlConnection ObjCnn;
    private SqlCommand ObjCmm = new SqlCommand();
    private String CnnStr;
    string str = @"Server=(local); Database=finaldoctor2; Integrated Security=TRUE";

    public DataBase()
    {
    CnnStr = str;
    ObjCnn = new SqlConnection();
    ObjCnn.ConnectionString = CnnStr;
    ObjCmm = new SqlCommand();
    ObjCmm.Connection = ObjCnn;
    }

    public void Connect()
    {
    try
    {
    ObjCnn.Open();
    }
    catch
    {
    throw new Exception("ارتباط با پایگاه داده برقرار نشد.");
    }
    }


    public void Disconnect()
    {
    try
    {
    ObjCnn.Close();
    }
    catch (Exception e)
    {
    ObjCnn.Dispose();//Releases all resources used by the Component.
    throw new Exception(e.Message);
    }
    }

    public void ExecuteSQL(string StrSQL)
    {
    Connect();
    ObjCmm.CommandText = StrSQL;
    try
    {
    ObjCmm.ExecuteNonQuery();
    }
    catch (Exception n)
    {
    throw new Exception("عملیات درج ثبت نشد.");

    }
    finally
    {
    Disconnect();
    }
    }



    public DataTable ExecuteSelectSQL(string StrSQL)
    {
    DataTable DT = new DataTable();
    SqlDataAdapter DA = new SqlDataAdapter();
    DA.SelectCommand = ObjCmm;
    DA.SelectCommand.CommandText = StrSQL;
    try
    {
    Connect();
    DA.SelectCommand.Connection = ObjCnn;
    DA.Fill(DT);
    return DT;
    }

    catch (Exception e)
    {
    throw new Exception(e.Message);
    }
    finally
    {
    Disconnect();
    }
    }


    }
    }


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;

    namespace finaldoctor2
    {
    public class ManegerHandller
    {
    private DataBase DBcnn;
    private String StrSQL;

    public ManegerHandller()
    {
    DBcnn = new DataBase();
    StrSQL = "";
    }

    public Boolean Update(Maneger M)
    {
    Boolean b = false;
    try
    {
    DataBase db = new DataBase();
    string SQL = @"update Maneger set name=N'" + M.Name + "',family=N'" + M.Family + "',code=N'" + M.Code + "',username=N'" + M.UserName + "',password=N'" + M.Password + "' where code=N'" + M.Code + "'";
    db.ExecuteSQL(SQL);
    b = true;
    }
    catch (Exception cv)
    {
    b = false;
    }
    return b;
    }


    public DataTable ShowAll()
    {
    string Sq = "select * from Maneger ORDER BY name,family Asc";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    }
    catch (Exception ex)
    {
    dt = null;
    }
    return dt;
    }



    public int Getid(string username, string pass)
    {
    int n = 0;
    string Sq = "select id from Maneger where username=N'" + username + "' and password='" + pass + "'";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    if (dt.Rows.Count != 0)
    {
    foreach (DataRow row in dt.Rows)
    foreach (var item in row.ItemArray)
    n = int.Parse(item.ToString());
    }
    else
    n = 0;
    }
    catch (Exception ex)
    {
    n = 0;
    }
    return n;
    }

    }
    }


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;

    namespace finaldoctor2
    {
    public class ClerkHandller
    {
    private DataBase DBcnn;
    private String StrSQL;

    public ClerkHandller()
    {
    DBcnn = new DataBase();
    StrSQL = "";
    }

    public Boolean Insert (Clerk C)
    {
    Boolean b = false;
    StrSQL = "Insert INTO Clerk VALUES (N'" + C.Name + "',N'" + C.Family + "',N'" + C.Dateinsert + "',N'" + C.UserName + "',N'" + C.Password + "',N'" + C.Code + "');";
    try
    {
    DBcnn.ExecuteSQL(StrSQL);
    b = true;
    }
    catch (Exception e)
    {
    b = false;

    }
    return b;
    }


    public Boolean Delete(string mellicode)
    {
    Boolean b = false;
    string SS = "delete from Clerk where mellicode=N'" + mellicode + "';";
    try
    {
    DBcnn.ExecuteSQL(SS);
    b = true;
    }
    catch (Exception vv)
    {
    b = false;
    }
    return b;
    }

    public Boolean Update(string name, string family, string dateinsert, string username, string password, string mellicode)
    {
    Boolean b = false;
    try
    {
    DataBase db = new DataBase();
    string SQL = @"update clerk set name=N'" + name + "',family=N'" + family + "',mellicode=N'" + mellicode + "',username=N'" + username + "',password=N'" + password + "' where mellicode=N'" + mellicode + "'";
    db.ExecuteSQL(SQL);
    b = true;
    }
    catch (Exception cv)
    {
    b = false;
    }
    return b;
    }



    public Boolean Update(string NewPass,string oldPass, int clerkid)
    {
    Boolean b = false;
    try
    {
    DataBase db = new DataBase();
    if (db.ExecuteSelectSQL("select * from clerk where id=N'" + clerkid + "' and Password=N'" + oldPass + "'").Rows.Count != 0)
    {
    string SQL = @"update Clerk set password=N'" + NewPass + "' where id=N'" + clerkid + "'";
    db.ExecuteSQL(SQL);
    b = true;
    }
    else
    b = false;
    }
    catch (Exception cv)
    {
    b = false;
    }
    return b;
    }


    public DataTable ShowAll(int clerkid)
    {
    string Sq = "select * from clerk where id=N'"+clerkid +"' ORDER BY Name,Family Asc";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    }
    catch (Exception ex)
    {
    dt = null;
    }
    return dt;
    }


    public DataTable ShowAll()
    {
    string Sq = "select * from clerk ORDER BY Name,Family Asc";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    }
    catch (Exception ex)
    {
    dt = null;
    }
    return dt;
    }




    public Boolean Exist(string mellicode)
    {
    Boolean b = false;
    string Sq = "select * from clerk where mellicode='" + mellicode + "'";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    if (dt.Rows.Count != 0)
    b = true;
    else
    b = false;
    }
    catch (Exception ex)
    {
    dt = null;
    }
    return b;
    }


    public int Getid(string username,string pass)
    {
    int n = 0;
    string Sq = "select id from clerk where username=N'" + username+ "' and password='"+pass+"'";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    if (dt.Rows.Count != 0)
    {
    foreach (DataRow row in dt.Rows)
    foreach (var item in row.ItemArray)
    n = int.Parse(item.ToString());
    }
    else
    n = 0;
    }
    catch (Exception ex)
    {
    n = 0;
    }
    return n;
    }

    }
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace finaldoctor2
    {
    public class Clerk:User
    {

    string userName;
    public string UserName
    {
    get { return userName; }
    set { userName = value; }
    }

    string password;
    public string Password
    {
    get { return password; }
    set { password = value; }
    }


    public Clerk()
    {
    name = "";
    family = "";
    mobile = "";
    dateinsert = "";
    userName = "";
    password = "";
    code = "";
    }

    public Clerk(string Name, string Family, string DateInsert, string UserName, string Password, string Code)
    {

    name = Name;
    family = Family;
    dateinsert = DateInsert;
    userName = UserName;
    password = Password;
    code = Code;
    }

    }
    }



    اینم کلاس login

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace finaldoctor2
    {
    public class LoginLogout
    {
    string dateLogIn;
    public string DateLogIn
    {
    get { return dateLogIn; }
    set { dateLogIn = value; }
    }

    string dateLogOut;

    public string DateLogOut
    {
    get { return dateLogOut; }
    set { dateLogOut = value; }
    }
    int clerkid;

    public int Clerkid
    {
    get { return clerkid ; }
    set { clerkid = value; }
    }
    int manid;

    public int Manid
    {
    get { return manid; }
    set { manid = value; }
    }

    public LoginLogout()
    {
    this.dateLogIn = "";
    this.dateLogOut = "";
    this.manid = 0;
    this.clerkid = 0;
    }

    public LoginLogout(string DateLogIn, string DateLogOut, int Clerkid, int MSanId)
    {
    this.dateLogIn = DateLogIn;
    this.dateLogOut = DateLogOut;
    this.manid = MSanId;
    this.clerkid = Clerkid;
    }





    }
    }



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;


    namespace finaldoctor2
    {
    public class LoginLogoutHandller
    {

    private DataBase DBcnn;
    private String StrSQL;

    public LoginLogoutHandller()
    {
    DBcnn = new DataBase();
    StrSQL = "";
    }

    public Boolean RecordTraffic(LoginLogout L)
    {
    Boolean b = false;
    StrSQL = "INSERT INTO loginlogout VALUES (N'" + L.DateLogIn + "',N'" + L.DateLogOut + "',N'" + L.Clerkid + "',N'" + L.Manid + "');";
    try
    {
    DBcnn.ExecuteSQL(StrSQL);
    b = true;
    }
    catch (Exception e)
    {
    b = false;
    }
    return b;
    }



    public Boolean loginClerk(string username, string pass)
    {
    Boolean b = false;
    string Sq = "select id from Clerk where UserName=N'" + username + "' and Password=N'" + pass + "';";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    if (dt.Rows.Count != 0)
    {
    b = true;
    }
    else
    b = false;
    }
    catch (Exception ex)
    {
    b = false;
    }
    return b;
    }


    public Boolean loginManager(string username, string pass)
    {
    Boolean b = false;
    string Sq = "select id from Manager where UserName=N'" + username + "' and Password=N'" + pass + "';";
    System.Data.DataTable dt = new System.Data.DataTable();
    try
    {
    dt = DBcnn.ExecuteSelectSQL(Sq);
    if (dt.Rows.Count != 0)
    {
    b = true;
    }
    else
    b = false;
    }
    catch (Exception ex)
    {
    b = false;
    }
    return b;
    }
    }
    }

  3. #3
    کاربر دائمی آواتار saba664
    تاریخ عضویت
    شهریور 1396
    محل زندگی
    کرمانشاه
    سن
    37
    پست
    147

    نقل قول: عدم خطا ولی کار نکردن کد

    کلاس مدیر و کابر عادی و لاگین نوشته شده بدون هیچ خطایی کد مربوط به فرم هم نوشته شده بدون هیچ خطایی بعد توی جدول اس کیو ال اسم خودمه تعریف کردم به عنوان مدیر ولی وقتی ورود می زنم میگه تعریف نشده همچین اسمی

  4. #4
    کاربر دائمی آواتار saba664
    تاریخ عضویت
    شهریور 1396
    محل زندگی
    کرمانشاه
    سن
    37
    پست
    147

    نقل قول: عدم خطا ولی کار نکردن کد

    من این سوال رو چند روز پیش پرسیدم

    الان جوابشو فهمیدم اینجا maneger رو اشتباه تایپی داشتم داخل کلاس loginhandller

    public Boolean loginManeger(string username, string pass)
    {
    Boolean b = false;
    string Sq = "select id from Maneger where UserName=N'" + username + "' and Password=N'" + pass + "';";
    System.Data.DataTable dt = new System.Data.DataTable();

    کد درست شد

تاپیک های مشابه

  1. کار نکردن کد jQuery در مستر پیج ASP
    نوشته شده توسط samangeraphic در بخش ASP.NET Web Forms
    پاسخ: 3
    آخرین پست: شنبه 05 آذر 1390, 00:21 صبح
  2. مبتدی: کار نکردن کد
    نوشته شده توسط css-man در بخش JavaScript و Framework های مبتنی بر آن
    پاسخ: 1
    آخرین پست: سه شنبه 01 آذر 1390, 23:31 عصر
  3. درست کار نکردن کد ها
    نوشته شده توسط akameli در بخش PHP
    پاسخ: 0
    آخرین پست: پنج شنبه 07 مرداد 1389, 23:33 عصر
  4. کار نکردن کد جاوا اسکریپت داخل فایر فاکس
    نوشته شده توسط r_mehrizi در بخش طراحی وب (Web Design)
    پاسخ: 2
    آخرین پست: سه شنبه 13 بهمن 1388, 11:03 صبح
  5. کار نکردن کد خواندن سریال هارد در ویستا و سون
    نوشته شده توسط mehdi1359a در بخش مباحث عمومی دلفی و پاسکال
    پاسخ: 2
    آخرین پست: دوشنبه 06 مهر 1388, 12:48 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •