کدها:
public static string code = "";
public static string gheymat = "0";
public static string codeKala = "";
private void frmSabteForoosheKala_Load(object sender, EventArgs e)
{
this.tbl_SefareshTableAdapter.Fill(this.dataSet1.t bl_Sefaresh);
this.tbl_factorTableAdapter.Fill(this.dataSet1.tbl _factor);
this.tbl_SefareshTableAdapter.Fill(this.dataSet1.t bl_Sefaresh);
//شماره فاکتور از 1000 شروع بشه
tbl_factorTableAdapter.Fill(dataSet1.tbl_factor);
if (dataSet1.tbl_factor.Rows.Count == 0)
txtShomareFactor.Text = "1000";
else
//به اولین شماره فاکتور یک مقدار اضافه کن (شماره فاکتورها به صورت نزولی مرتب شده)ی
txtShomareFactor.Text = (int.Parse(dataSet1.tbl_factor.Rows[0][0].ToString()) + 1).ToString();
}
private void frmSabteForoosheKala_Activated(object sender, EventArgs e)
{
if (code != "")
{
txtCodeCustomer.Text = code;
code = "";
}
if (codeKala != "")
{
tbl_factorTableAdapter.FillByshomareFactor(dataSet 1.tbl_factor, txtShomareFactor.Text);
// tbl_SefareshTableAdapter.InsertQuery1(txtCodeCusto mer.Text,codeKala,1,decimal.Parse(gheymat),decimal .Parse(gheymat));
if (dataSet1.tbl_factor.Rows.Count == 0)
{
tbl_factorTableAdapter.InsertQuery1(txtShomareFact or.Text, txtCodeCustomer.Text, txtTarikh.Text, "11");
}
tbl_SefareshTableAdapter.InsertQuery1(txtShomareFa ctor.Text, codeKala, 1, decimal.Parse(gheymat), decimal.Parse(gheymat));
codeKala = "";
tbl_SefareshTableAdapter.FillByfactor(dataSet1.tbl _Sefaresh, txtShomareFactor.Text);
}
}
private void txtShomareFactor_TextChanged(object sender, EventArgs e)
{
tbl_factorTableAdapter.FillByshomareFactor(dataSet 1.tbl_factor, txtShomareFactor.Text);
//شماره مشتری را طبق شماره فاکتور در قسمت مربوطه قرار می دهد
txtCodeCustomer.Text = dataSet1.tbl_factor.Rows[0][1].ToString();
txtTarikh.Text = dataSet1.tbl_factor.Rows[0][2].ToString();
tbl_SefareshTableAdapter.FillByfactor(dataSet1.tbl _Sefaresh, txtShomareFactor.Text);
}