private void btnUpdate_Click(object sender, EventArgs e) { // Declare local variables and objects... int intPosition; // Save the current record position... intPosition = objCurrencyManager.Position; // Set the SqlCommand object properties... hazineh_types te = new hazineh_types(); te.id = long.Parse(txtid.Text); te.htype = txthtype.Text.Trim(); te.Update(); hazineh ha = new hazineh(); // Close the connection... // Fill the DataSet and bind the fields... FillDataSetAndView(); BindFields(); // Set the record position // to the one that you saved... objCurrencyManager.Position = intPosition; // Show the current record position... ShowPosition(); // Display a message that the record was updated... toolStripStatusLabel1.Text = "عملیات ویرایش رکورد با موفقیت انجام شد"; }
private void btnAdd_Click(object sender, EventArgs e) { string position; hazineh_types te = new hazineh_types(); te.id = long.Parse(txtid.Text); te.htype = txthtype.Text.Trim(); te.Add(); FillDataSetAndView(); BindFields(); // Set the record position // to the one that you saved... objCurrencyManager.Position = objCurrencyManager.Count - 1; // Show the current record position... ShowPosition(); // Display a message that the record was added... toolStripStatusLabel1.Text = "عملیات درج رکورد با موفقیت انجام شد"; // Save the current record position... position = objCurrencyManager.Position.ToString(); btnNew_Click(null, null); }
private void FillDataSetAndView() { // Initialize a new instance of the DataSet object... hazineh_types te = new hazineh_types(); datat = te.Select(); // Set our CurrencyManager object // to the DataView object... objCurrencyManager = (CurrencyManager)(this.BindingContext[datat]); }
private void button1_Click_1(object sender, EventArgs e) { frmShortHazinehInp fbi = new frmShortHazinehInp(); fbi.ShowDialog(); hazineh_types ba = new hazineh_types(); txttype.DataSource = ba.SelectforComboBox(); txttype.DisplayMember = "htype"; txttype.Focus(); txttype.SelectAll(); }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dr; dr = MessageBox.Show("آیا از حذف نوع هزینه اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { hazineh_types ac = new hazineh_types(); ac.id = long.Parse(txtid.Text.Trim()); ac.Delete(); FillDataSetAndView(); BindFields(); ShowPosition(); // Display a message that the record was updated... toolStripStatusLabel1.Text = "عملیات حذف نوع هزینه با موفقیت انجام شد"; } }
public void idsearch_Click() { hazineh_types ba = new hazineh_types(); txttype.DataSource = ba.SelectforComboBox(); txttype.DisplayMember = "htype"; hazineh fac = new hazineh(); fac.radif = long.Parse(txtradif.Text); dt = fac.SelectForEslah(); if (dt.Rows.Count > 0) { btnUpdate.Enabled = true; txtradif.Enabled = false; grpinfo_box.Enabled = true; // Clear any previous bindings & Add new bindings to the DataView object... foreach (Control c in grpinfo_box.Controls) { if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(ComboBox) || c.GetType() == typeof(DateMaskedTextbox) || c.GetType() == typeof(CurrencyTextBox)) { if (c != txtradif) { c.Text = dt.Rows[0][c.Name.Substring(3)].ToString(); } } } // End of Clearing & Adding of Controls Binding txtdate.Focus(); } else { MessageBox.Show("شماره مشخصه در سیستم موجود نمی باشد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frmHazinehInp_Load(object sender, EventArgs e) { System.Globalization.CultureInfo inp = new System.Globalization.CultureInfo("fa-IR"); InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(inp); cur_date = Date.currentDate_Getter(); hazineh_types ba = new hazineh_types(); txttype.DataSource = ba.SelectforComboBox(); txttype.DisplayMember = "htype"; FillDataSetAndView(); if (objCurrencyManager.Count == 0) { grpinfo_box.Enabled = false; btnAdd.Enabled = false; btnMoveFirst.Enabled = false; btnMovePrevious.Enabled = false; btnMoveNext.Enabled = false; btnMoveLast.Enabled = false; btnNew.Visible = true; txtRecordPosition.Text = "No Records"; toolStripStatusLabel1.Text = "آماده ایجاد رکورد جدید"; txtdate.Text = cur_date; } else { BindFields(); objCurrencyManager.Position = objCurrencyManager.Count - 1; ShowPosition(); btnAdd.Enabled = false; } }