PDA

View Full Version : فراخوانی متد سازنده کلاس و خطای ClassMethod does not contain a constructor that takes 25 arguments



saba664
سه شنبه 07 آذر 1396, 09:51 صبح
با سلام خدمت همه

کسی میدونه علت این خطا چیه؟


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

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

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

public Boolean Insert(sabt C)
{
Boolean b = false;
StrSQL = "INSERT INTO sabt VALUES (N'" + C.Name + "',N'" + C.Family + "',N'" + C.Father + "',N'" + C.Jenseyat + "',N'" + C.Nezam + "',N'" + C.Code + "',N'" + C.Country + "',N'" + C.Shahrestan + "',N'" + C.Telwork + "',N'" + C.Mobile + "',N'" + C.Reshteh + "',N'" + C.Madarak + "',N'" + C.Vemployment + "',N'" + C.Khed1 + "',N'" + C.Khed2 + "',N'" + C.Khed3 + "',N'" + C.Khed4 + "',N'" + C.Heat + "',N'" + C.Matab + "',N'" + C.Address + "',N'" + C.Photo + "',N'" + C.Parvaneh + "',N'" + C.Vazeat + "');";
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 sabt 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 Father, Boolean Jenseyat, string Nezam, string Code, string Country, string Shahrestan, string Telwork, string Mobile, string Reshteh, string Madarak, string Vemployment, string Khed1, string Khed2, string Khed3, string Khed4, Boolean heat, Boolean matab, string Address, byte photo, Boolean Parvaneh, Boolean Vazeat)
{
Boolean b = false;
try
{
DataBase db = new DataBase();
string SQL = @"update sabt set name=N'" + Name + "',Family=N'" + Family + "',Father=N'" + Father + "',Code=N'" + Code + "',Address=N'" + Address + "',Mobile=N'" + Mobile + "' where Code=N'" + Code + "'";
db.ExecuteSQL(SQL);
b = true;
}
catch (Exception cv)
{
b = false;
}
return b;
}





public DataTable ShowAll(int sabtid)
{
string Sq = "select * from sabt where id=N'" + sabtid + "' 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 sabt 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 code)
{
Boolean b = false;
string Sq = "select * from sabt where Code='" + code + "'";
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;
}
}
}







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


namespace finaldoctor2
{
public class sabt:User
{
string username;
public string Username
{
get { return username ; }
set { username = value; }
}
string password;
public string Password
{
get { return password ; }
set { password = value; }
}
public sabt()
{
name = "";
family = "";
father = "";
// jenseyat = "";
nezam = "";
code = "";
country = "";
shahrestan = "";
telwork = "";
mobile = "";
reshteh = "";
// madrak = "";
vemployment = "";
khed1 = "";
khed2 = "";
khed3 = "";
khed4 = "";
// heat = "";
// matab = "";
address = "";
// parvaneh = "";
// vazeat = "";
mmt = "";

}
public sabt(string name, string family, string father, Boolean jenseyat,string nezam,string code,string country,string shahrestan,string telwork,string mobile,string reshteh,Boolean madarak,string vemployment,string khed1,string khed2,string khed3,string khed4,Boolean heat,Boolean matab,string address,byte photo,Boolean parvaneh,Boolean vazeat,string mmt)
{
name = Name;
family = Family;
father = Father;
jenseyat = Jenseyat;
nezam = Nezam;
code = Code;
country = Country;
jenseyat = Jenseyat;
nezam = Nezam;
code = Code;
country = Country;
shahrestan = Shahrestan;
telwork = Telwork;
mobile = Mobile;
reshteh = Reshteh;
madarak = Madarak;
vemployment = Vemployment;
khed1 = Khed1;
khed2 = Khed2;
khed3 = Khed3;
khed4 = Khed4;
heat = Heat;
matab = Matab;
address = Address;
photo = Photo;
parvaneh = Parvaneh;
vazeat = Vazeat;
mmt = Mmt;



}



}
}




اینا دو تا کلاس هام هستن کد زیر هم کدیه که خطا میده از قسمت S= sabt


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 Fsabt : Form
{
public Fsabt()
{
InitializeComponent();
}

sabt S;
sabtHandller sab = new sabtHandller();
int SCode = 0;
sabt SUpdate;


private void button6_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "jpg Files |*.jpg|PNG FIles |*.png";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
pictureBox1.Image = new Bitmap(openFileDialog1.FileName);
}

private void button1_Click(object sender, EventArgs e)
{
try
{
S = new sabt (txtname.Text , txtfamily.Text , txtfa.Text ,comboBox1.Text,txtname.Text,txtcode.Text,txtcon,c omboBox2.Text,comboBox3.Text,txttel.Text,txtmobil. Text,comboBox4.Text,comboBox6.Text,comboBox5.Text, comboBox9.Text,comboBox7.Text,comboBox10.Text,comb oBox8.Text,comboBox11.Text,comboBox12.Text,comboBo x13.Text,txtaddress.Text,comboBox14.Text,checkBox7 .Checked,pictureBox1.Image
);

if (txtname.Text != "" && txtcode.Text != "" )
{
if (!sab.Exist(txtcode.Text ))
{
if (sab.Insert(S))
{
MessageBox.Show("داده ها با موفقیت ثبت شدند", "موفقیت", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
dataGridView1.DataSource = sab.ShowAll();
}
else
MessageBox.Show("عدم موفقیت در ثبت داده ها !!!! لطفا علت را بررسی کنید", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}
else
MessageBox.Show("دارنده این کد ملی قبلا در بانک ذخیره شده است");
}

else
{
MessageBox.Show("فیلد ها را کامل وارد کنید", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}
}
catch (Exception ex)
{
MessageBox.Show("خطای سیستم : " + ex.Message);
}
}

}
}




147167

محمد آشتیانی
سه شنبه 07 آذر 1396, 10:24 صبح
سلام
نکته اول: در انتخاب نام تاپیک دقت کنید ، این عناوین کلی بی درنگ حذف خواهند شد.

اما سوالتون

در کلاس Sabt ، متد سازنده 24 پارامتر ورودی داره ، اما شما در جایی که فراخوانیش کردید ، 25 پارامتر بهش پاس دادید (متن خطا هم کاملا گویاست)