ehsan7007
دوشنبه 26 تیر 1391, 11:45 صبح
سلام.
وقتی برناممو اجرا می کنم و در تکست باکس ها متن می نویسم و سپس روی سیو کلیک می کنم به جای ذخیره این پنجره می یاد:
http://rezashahabi.persiangig.com/2.PNG
طرح برنامم اینه:
http://rezashahabi.persiangig.com/1.PNG
و کد برنامم :
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 WindowsFormsApplication16
{
public partial class Form1 : Form
{
private System.Windows.Forms.TextBox money;
private System.Windows.Forms.TextBox type;
private System.Windows.Forms.DataGrid DataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
#region "Variabels"
string nam, famil;
#endregion
#region "FormLoad"
private void Form1_Load(System.Object sender, System.EventArgs e)
{
System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("fa-ir");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language);
DataTable dt = new DataTable();
DataBase db = new DataBase();
dt = db.MySelect("select * from telephon");
DataGrid1.DataSource = dt;
}
#endregion
public Form1()
{
InitializeComponent();
}
private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"
money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();
#endregion
}
private void save_click(object sender, EventArgs e)
{
#region "Darj dar bank"
DataBase db = new DataBase();
db.DoCommand("insert into DataTable1 values('" + type.Text + "','" + money.Text + "','" + "')");
Form1_Load(sender, e);
MessageBox.Show("Inserted");
#endregion
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"
money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();
#endregion
}
private void money_TextChanged(object sender, EventArgs e)
{
}
private void type_TextChanged(object sender, EventArgs e)
{
}
}
}
مشکل چیه؟؟
وقتی برناممو اجرا می کنم و در تکست باکس ها متن می نویسم و سپس روی سیو کلیک می کنم به جای ذخیره این پنجره می یاد:
http://rezashahabi.persiangig.com/2.PNG
طرح برنامم اینه:
http://rezashahabi.persiangig.com/1.PNG
و کد برنامم :
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 WindowsFormsApplication16
{
public partial class Form1 : Form
{
private System.Windows.Forms.TextBox money;
private System.Windows.Forms.TextBox type;
private System.Windows.Forms.DataGrid DataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
#region "Variabels"
string nam, famil;
#endregion
#region "FormLoad"
private void Form1_Load(System.Object sender, System.EventArgs e)
{
System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("fa-ir");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language);
DataTable dt = new DataTable();
DataBase db = new DataBase();
dt = db.MySelect("select * from telephon");
DataGrid1.DataSource = dt;
}
#endregion
public Form1()
{
InitializeComponent();
}
private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"
money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();
#endregion
}
private void save_click(object sender, EventArgs e)
{
#region "Darj dar bank"
DataBase db = new DataBase();
db.DoCommand("insert into DataTable1 values('" + type.Text + "','" + money.Text + "','" + "')");
Form1_Load(sender, e);
MessageBox.Show("Inserted");
#endregion
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
#region "DataGrid1_MouseUp-Bind to TextBoxes"
money.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString().Trim();
type.Text = DataGrid1[DataGrid1.CurrentRowIndex, 1].ToString().Trim();
#endregion
}
private void money_TextChanged(object sender, EventArgs e)
{
}
private void type_TextChanged(object sender, EventArgs e)
{
}
}
}
مشکل چیه؟؟