private void btnUpdate_Click(object sender, EventArgs e) { try { System.Globalization.PersianCalendar x = new System.Globalization.PersianCalendar(); DateTime dd = x.ToDateTime(int.Parse(txtdate.Text.Substring(0, 4)), int.Parse(txtdate.Text.Substring(5, 2)), int.Parse(txtdate.Text.Substring(8, 2)), 0, 0, 0, 0, 0); // Updating the Data to the DataBase hazineh fa = new hazineh(); fa.radif = long.Parse(txtradif.Text); fa.type = txttype.Text.Trim(); fa.date = txtdate.Text; fa.mablagh = long.Parse(txtmablagh.Text); fa.comments = txtcomments.Text.Trim(); fa.update(); // End of Updating Data to the DataBase this.Close(); } catch { MessageBox.Show("لطفا اطلاعات وارد شده را بررسی نمایید"); } }
private void BindFields() { // 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(DateMaskedTextbox) || c.GetType() == typeof(CurrencyTextBox) || c.GetType() == typeof(ComboBox)) { c.DataBindings.Clear(); c.DataBindings.Add("Text", datat, c.Name.Substring(3)); } } // End of Clearing & Adding of Controls Binding // Create the list to use as the custom source. AutoCompleteStringCollection source = new AutoCompleteStringCollection(); hazineh ac = new hazineh(); ac.type = txttype.Text.Trim(); DataTable hazinehdt = new DataTable(); hazinehdt = ac.SelectforAutoComplete(); foreach (DataRow dtrow in hazinehdt.Rows) { source.Add(dtrow["comments"].ToString().Trim()); } // Create and initialize the text box. txtcomments.AutoCompleteCustomSource = source; txtcomments.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtcomments.AutoCompleteSource = AutoCompleteSource.CustomSource; // Display a ready status... toolStripStatusLabel1.Text = "آماده عملیات"; }
private void frmHazinehView_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 fa = new hazineh(); DataTable dt = new DataTable(); dt = fa.Select(); grdDataViewer.DataSource = dt; grdDataViewer.AutoGenerateColumns = true; string[] col_headers = { "مشخصه", "نوع هزینه", "تاریخ", "مبلغ", "شرح هزینه" }; int[] col_width = { 60, 100, 80, 80, 270 }; for (int i = 0; i < col_headers.Length; i++) { grdDataViewer.Columns[i].HeaderText = col_headers[i].ToString(); grdDataViewer.Columns[i].Width = col_width[i]; } DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; grdDataViewer.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Format = "N0"; dataGridViewCellStyle1.NullValue = null; grdDataViewer.Columns["mablagh"].DefaultCellStyle = dataGridViewCellStyle1; }
private void btnedit_Click(object sender, EventArgs e) { if (grdDataViewer.CurrentRow != null) { int row = grdDataViewer.CurrentRow.Index; string val = grdDataViewer["radif", row].Value.ToString(); frmHazinehEdit fse = new frmHazinehEdit(); fse.txtradif.Text = val; fse.idsearch_Click(); fse.ShowDialog(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } } }
private void btndel_Click(object sender, EventArgs e) { DialogResult dr; dr = MessageBox.Show("آیا از حذف هزینه اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { int irow = grdDataViewer.CurrentRow.Index; string val = grdDataViewer["radif", irow].Value.ToString(); hazineh fac = new hazineh(); fac.radif = long.Parse(val); fac.Delete(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } } }
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 FillDataSetAndView() { // Initialize a new instance of the DataSet object... hazineh dp = new hazineh(); datat = dp.Select(); // Set our CurrencyManager object to the DataView object... objCurrencyManager = (CurrencyManager)(this.BindingContext[datat]); }
private void btnfilter_Click(object sender, EventArgs e) { try { Boolean check = false; string SQL = "select * from hazineh where "; check = false; if (txttype.Text != "") { SQL = SQL + "type Like N'%" + txttype.Text.Trim() + "%'AND "; check = true; } if (txtfrom_date.MaskCompleted) { SQL = SQL + "date>=N'" + txtfrom_date.Text.Trim() + "'AND "; check = true; } if (txtto_date.MaskCompleted) { SQL = SQL + "date <=N'" + txtto_date.Text.Trim() + "'AND "; check = true; } if (check == true) { SQL = SQL.Remove(SQL.Length - 4); } hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Search(SQL); dataGridView1.DataSource = dt; long sum = 0; for (int i = 0; i < dt.Rows.Count; i++) { sum += Convert.ToInt64(dt.Rows[i]["mablagh"]); } txtsum.Visible = true; txtsum.Text = sum.ToString("N0"); } catch (Exception) { MessageBox.Show("لطفا اطلاعات جستجو را به صورت صحیح وارد نمایید!!!"); txttype.Text = ""; } }
private void frmHazinehView_Activated(object sender, EventArgs e) { if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } }
private void TextChanged_Action(object sender, EventArgs e) { if (!txtdate.MaskCompleted && !txttodate.MaskCompleted) { btnfilter.Enabled = false; hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } else { btnfilter.Enabled = true; } }
private void txtcus_name_TextChanged(object sender, EventArgs e) { if (!txtto_date.MaskCompleted && !txtfrom_date.MaskCompleted && txttype.Text == "") { btnfilter.Enabled = false; hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); dataGridView1.DataSource = dt; txtsum.Text = ""; } else { btnfilter.Enabled = true; } }
private void btnadd_Click(object sender, EventArgs e) { frmHazinehInp ffi = new frmHazinehInp(); ffi.MdiParent = this.MdiParent; ffi.Show(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { hazineh pm = new hazineh(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } }
private void TextChanged_Action(object sender, EventArgs e) { if (sender == txttype) { // Create the list to use as the custom source. AutoCompleteStringCollection source = new AutoCompleteStringCollection(); hazineh ac = new hazineh(); ac.type = txttype.Text.Trim(); DataTable hazinehdt = new DataTable(); hazinehdt = ac.SelectforAutoComplete(); foreach (DataRow dtrow in hazinehdt.Rows) { source.Add(dtrow["comments"].ToString().Trim()); } // Create and initialize the text box. txtcomments.AutoCompleteCustomSource = source; txtcomments.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtcomments.AutoCompleteSource = AutoCompleteSource.CustomSource; } if (sender == txtmablagh) { if (txtmablagh.Text == "") { txtmablagh.Text = "0"; txtmablagh.Focus(); txtmablagh.SelectAll(); } } if (txtradif.Text == "" || txtmablagh.Text.Trim() == "" || txttype.Text.Trim() == "" || txtcomments.Text.Trim() == "" || !txtdate.MaskCompleted) { btnUpdate.Enabled = false; } else { btnUpdate.Enabled = true; } }
private void btnAdd_Click(object sender, EventArgs e) { try { System.Globalization.PersianCalendar x = new System.Globalization.PersianCalendar(); DateTime dd = x.ToDateTime(int.Parse(txtdate.Text.Substring(0, 4)), int.Parse(txtdate.Text.Substring(5, 2)), int.Parse(txtdate.Text.Substring(8, 2)), 0, 0, 0, 0, 0); // Inserting the Data to the DataBase hazineh fa = new hazineh(); fa.radif = long.Parse(txtradif.Text); fa.type = txttype.Text.Trim(); fa.date = txtdate.Text; fa.mablagh = long.Parse(txtmablagh.Text); fa.comments = txtcomments.Text; fa.Add(); // End of Inserting Data to the DataBase 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 = "عملیات ثبت هزینه با موفقیت انجام شد"; btnNew_Click(null, null); } catch { MessageBox.Show("لطفا اطلاعات وارد شده را بررسی نمایید"); } }
private void btnfilter_Click(object sender, EventArgs e) { try { Boolean check = false; string SQL = "select * from hazineh where "; check = false; if (txtdate.MaskCompleted) { SQL = SQL + "date>=N'" + txtdate.Text.Trim() + "'AND "; check = true; } if (txttodate.MaskCompleted) { SQL = SQL + "date<=N'" + txttodate.Text.Trim() + "'AND "; check = true; } if (check == true) { SQL = SQL.Remove(SQL.Length - 4); } hazineh rm = new hazineh(); DataTable dt = new DataTable(); dt = rm.Search(SQL); grdDataViewer.DataSource = dt; } catch (Exception) { MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!"); txtdate.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 frmHazinehShow_Load(object sender, EventArgs e) { System.Globalization.CultureInfo inp = new System.Globalization.CultureInfo("fa-IR"); InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(inp); hazineh st = new hazineh(); DataTable dt; dt = st.Select(); dataGridView1.DataSource = dt; dataGridView1.AutoGenerateColumns = true; string[] col_headers = { "ردیف", "شماره سند", "نوع هزینه", "تاریخ", "مبلغ", "توضیحات" }; int[] col_width = { 50, 70, 100, 80, 60, 200 }; for (int i = 0; i < col_headers.Length; i++) { dataGridView1.Columns[i].HeaderText = col_headers[i].ToString(); dataGridView1.Columns[i].Width = col_width[i]; } DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.WhiteSmoke; dataGridView1.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); dataGridViewCellStyle2.Format = "N0"; dataGridViewCellStyle2.NullValue = null; dataGridView1.Columns["mablagh"].DefaultCellStyle = dataGridViewCellStyle2; dataGridView1.ClearSelection(); btnexit.Focus(); }