private void btnRefresh_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("income"); dt.Columns.Add("paid"); dt.Columns.Add("hazineh"); dt.Columns.Add("month"); ghabz gh = new ghabz(); string year = txtyear.Value.ToString() + @"/"; string[] fromdate = new string[12]; string[] todate = new string[12]; string[] months = { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" }; for (int i = 1; i <= 12; i++) { fromdate[i - 1] = year + i.ToString("00") + @"/01"; todate[i - 1] = year + i.ToString("00") + @"/31"; DataTable dtrows = gh.Search("SELECT isnull(SUM(mablagh),0) AS income FROM GHABZ WHERE (date>=N'" + fromdate[i - 1] + "' and date<=N'" + todate[i - 1] + "' )"); DataTable dtpaidrows = gh.Search("SELECT isnull(SUM(mablagh),0) AS paid FROM payments WHERE (paidformonth>=N'" + months[i - 1] + "' and paidformonth<=N'" + months[i - 1] + "' )"); DataTable dthazinehrows = gh.Search("SELECT isnull(SUM(mablagh),0) AS hazineh FROM hazineh WHERE (date>=N'" + fromdate[i - 1] + "' and date<=N'" + todate[i - 1] + "' )"); dt.Rows.Add(new object[] { dtrows.Rows[0]["income"].ToString(), dtpaidrows.Rows[0]["paid"].ToString(), dthazinehrows.Rows[0]["hazineh"].ToString(), months[i - 1] }); } this.reportDataSource1.Value = dt; this.reportViewer1.RefreshReport(); }
private void fillGhabzInfo() { grdDataViewGhabz.AutoGenerateColumns = true; ghabz gh = new ghabz(); gh.stdno = txtstdno.Text; grdDataViewGhabz.DataSource = gh.SelectbyStdId(); string[] col_headers = { "شماره قبض", "ش هنرجویی", "نام و نام خانوادگی", "کلاس", "تاریخ", "تاریخ پایان تسویه", "ماه تسویه", "هزینه دوره", "مبلغ دریافتی", "توضیحات" }; int[] col_width = { 70, 60, 120, 90, 80, 80, 70, 70, 70, 180 }; for (int i = 0; i < col_headers.Length; i++) { grdDataViewGhabz.Columns[i].HeaderText = col_headers[i].ToString(); grdDataViewGhabz.Columns[i].Width = col_width[i]; } DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; grdDataViewGhabz.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Format = "N0"; dataGridViewCellStyle1.NullValue = null; grdDataViewGhabz.Columns["mablagh"].DefaultCellStyle = dataGridViewCellStyle1; grdDataViewGhabz.Columns["paid"].DefaultCellStyle = dataGridViewCellStyle1; }
private void btnedit_Click_1(object sender, EventArgs e) { if (grdDataViewer.CurrentRow != null) { int col = 0; int row = grdDataViewer.CurrentRow.Index; string val = grdDataViewer[col, row].Value.ToString(); frmGhabzEdit fge = new frmGhabzEdit(); fge.txtid.Text = val; fge.stdno = grdDataViewer["stdno", row].Value.ToString(); fge.idsearch_Click(); fge.ShowDialog(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { ghabz pm = new ghabz(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } } }
private void btnUpdate_Click(object sender, EventArgs e) { std stdn = new std(); stdn.stdno = txtstdno.Text; if (!stdn.SelectfornameCheck().Equals(txtname.Text)) { MessageBox.Show("نام هنرجو با شماره پرونده مطابقت ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); txtname.Focus(); return; } ghabz gh = new ghabz(); gh.id = txtid.Text; gh.stdno = txtstdno.Text; gh.name = txtname.Text.Trim(); gh.artcourse = txtartcourse.Text.Trim(); gh.date = txtdate.Text; gh.lastcheck = txtlastcheck.Text; gh.lastdate = txtlastdate.Text; gh.mablagh = long.Parse(txtmablagh.Text); gh.sharh = txtsharh.Text; gh.Update(); MessageBox.Show("قبض با موفقیت ویرایش گردید"); this.Close(); }
private void newform() { ghabz gh = new ghabz(); txtid.Text = gh.Selectmaxid(); DataTable lastmablagh = gh.Search("select top 1(mablagh) from ghabz order by id desc"); if (lastmablagh.Rows.Count > 0) { txtmablagh.Text = lastmablagh.Rows[0][0].ToString(); } else { txtmablagh.Text = "0"; } txtdate.Text = cur_date; txtlastdate.Text = Date.returnLastDateOfaDate(txtdate.Text); txtsharh.Text = ""; groupBox1.Focus(); txtname.Focus(); }
private void fillInfo() { ghabz gh = new ghabz(); txtid.Text = gh.Selectmaxid(); DataTable lastmablagh = gh.Search("select top 1(mablagh) from ghabz order by id desc"); if (lastmablagh.Rows.Count > 0) { txtmablagh.Text = lastmablagh.Rows[0][0].ToString(); } else { txtmablagh.Text = "0"; } txtdate.Text = cur_date; txtsharh.Text = ""; std st = new std(); DataTable dtstdname = new DataTable(); dtstdname = st.Search("SELECT stdno,name FROM std where stdno=" + stdno); txtname.Text = dtstdname.Rows[0]["name"].ToString(); txtstdno.Text = dtstdname.Rows[0]["stdno"].ToString(); txtlastdate.Text = Date.returnLastDateOfaDate(txtdate.Text); groupBox1.Focus(); txtname.Focus(); }
private void Peygiri_Date() { ghabz gh = new ghabz(); DataTable dt = new DataTable(); gh.PeygiriDate = txtdate.Text.Substring(0, 4) + "/" + (txtmonth.SelectedIndex + 1).ToString("00") + "/01"; dt = gh.PeygiribyDate(); dataGridView1.DataSource = dt; }
private void Peygiri_Day() { ghabz gh = new ghabz(); DataTable dt = new DataTable(); gh.PeygiriDate = txtdate.Text; gh.PeygiriDay = txtclday.Text; dt = gh.PeygiribyDay(); dataGridView1.DataSource = dt; }
private void cmdadd_Click(object sender, EventArgs e) { std stdn = new std(); stdn.stdno = txtstdno.Text; if (!stdn.SelectfornameCheck().Equals(txtname.Text)) { MessageBox.Show("نام هنرجو با شماره پرونده مطابقت ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); txtname.Focus(); return; } ghabz gh = new ghabz(); gh.id = txtid.Text; gh.stdno = txtstdno.Text; gh.name = txtname.Text.Trim(); gh.artcourse = txtartcourse.Text.Trim(); gh.date = txtdate.Text; gh.lastcheck = txtlastcheck.Text; gh.lastdate = txtlastdate.Text; gh.mablagh = long.Parse(txtmablagh.Text); gh.paid = long.Parse(txtpaid.Text); gh.sharh = txtsharh.Text; gh.Update(); if (!stdno.Equals(txtstdno.Text)) { std_history st = new std_history(); st.ghabz_id = txtid.Text; st.stdno = stdno; // old stdno st.Delete(); pardakht(); Daryaft(); } else { std_history sh = new std_history(); sh.ghabz_id = txtid.Text; sh.stdno = txtstdno.Text;; sh.sharh = "شهریه " + txtlastcheck.Text + "-" + txtsharh.Text; sh.date = txtdate.Text; sh.bedehkari = long.Parse(txtmablagh.Text); sh.bestankari = long.Parse(txtmablagh.Text); sh.UpdateAfterEslahGhabz(); } MessageBox.Show("قبض با موفقیت ویرایش گردید"); this.Close(); }
public void idsearch_Click() { Courses co = new Courses(); DataTable dtname = new DataTable(); dtname = co.Search("SELECT coursename FROM courses order by coursename"); txtartcourse.DataSource = dtname; txtartcourse.DisplayMember = "coursename"; txtartcourse.ValueMember = "coursename"; std st = new std(); DataTable dtstdname = new DataTable(); dtstdname = st.Search("SELECT name, stdno FROM std order by name"); txtname.DataSource = dtstdname; txtname.DisplayMember = "name"; txtname.ValueMember = "name"; txtstdno.DataBindings.Clear(); txtstdno.DataBindings.Add("Text", dtstdname, "stdno"); ghabz gh = new ghabz(); gh.id = txtid.Text; DataTable dt = gh.Selectforedit(); if (dt.Rows.Count > 0) { btnUpdate.Enabled = true; txtid.Enabled = false; groupBox1.Enabled = true; // Clear any previous bindings & Add new bindings to the DataView object... foreach (Control c in groupBox1.Controls) { if (c.GetType() == typeof(FiveCharTextBox) || c.GetType() == typeof(NormalCombobox) || c.GetType() == typeof(DateMaskedTextbox) || c.GetType() == typeof(CurrencyTextBox) || c.GetType() == typeof(NormalTextbox)) { if (c != txtlastdate && c != txtmandeh && c != txtlastcheck) { c.Text = dt.Rows[0][c.Name.Substring(3)].ToString(); } } } txtlastdate.Text = dt.Rows[0]["lastdate"].ToString(); txtlastcheck.Text = dt.Rows[0]["lastcheck"].ToString(); // End of Clearing & Adding of Controls Binding txtstdno.Focus(); } else { MessageBox.Show("شماره قبض در سیستم موجود نمی باشد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void TextChanged_Action(object sender, EventArgs e) { if (txtartcourse.Text == "" && txtname.Text == "" && !txtmos_date.MaskCompleted && !txttodate.MaskCompleted && !txtlastdatefrom.MaskCompleted && !txtlastdateto.MaskCompleted && !checkBox1.Checked) { btnfilter.Enabled = false; ghabz pm = new ghabz(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } else { btnfilter.Enabled = true; } }
private void UpdateGhabz() { ghabz gh = new ghabz(); gh.stdno = txtstdno.Text; ghabzGridView.DataSource = gh.SelectbyStdId(); ghabzGridView.AutoGenerateColumns = true; string[] col_headers = { "شماره قبض", "ش هنرجویی", "نام و نام خانوادگی", "کلاس", "تاریخ", "تاریخ پایان تسویه", "ماه تسویه", "مبلغ", "توضیحات" }; int[] col_width = { 70, 60, 120, 90, 80, 80, 70, 70, 180 }; for (int i = 0; i < col_headers.Length; i++) { ghabzGridView.Columns[i].HeaderText = col_headers[i].ToString(); ghabzGridView.Columns[i].Width = col_width[i]; } DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; ghabzGridView.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; }
private void btnadd_Click(object sender, EventArgs e) { frmGhabzDaryaft fgd = new frmGhabzDaryaft(); //fgd.cur_date = this.cur_date; //fgd.MdiParent = this.MdiParent; //int m = int.Parse(cur_date.Substring(5, 2)); //fgd.txtlastcheck.SelectedIndex = m - 1; fgd.ShowDialog(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { ghabz pm = new ghabz(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } }
private void btndel_Click_1(object sender, EventArgs e) { if (grdDataViewer.CurrentRow != null) { DialogResult dr; dr = MessageBox.Show("آیا از حذف این قبض اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { int icol = 0; int irow = grdDataViewer.CurrentRow.Index; string val = grdDataViewer[icol, irow].Value.ToString(); ghabz gha = new ghabz(); gha.id = val; gha.Delete(); std_history st = new std_history(); st.ghabz_id = val; st.stdno = grdDataViewer["stdno", irow].Value.ToString(); st.Delete(); if (btnfilter.Enabled == true) { btnfilter.PerformClick(); } else { ghabz pm = new ghabz(); DataTable dt = new DataTable(); dt = pm.Select(); grdDataViewer.DataSource = dt; } } } }
private void btnfilter_Click(object sender, EventArgs e) { // try // { Boolean check = false; string SQL = "select * from ghabz where "; check = false; if (txtartcourse.Text != "") { SQL = SQL + "artcourse like N'%" + txtartcourse.Text.Trim() + "%'AND "; check = true; } if (txtname.Text != "") { SQL = SQL + "name like N'%" + txtname.Text.Trim() + "%'AND "; check = true; } if (txtmos_date.MaskCompleted) { checkBox1.Checked = false; SQL = SQL + "date>=N'" + txtmos_date.Text.Trim() + "'AND "; check = true; } if (txttodate.MaskCompleted) { checkBox1.Checked = false; SQL = SQL + "date<=N'" + txttodate.Text.Trim() + "'AND "; check = true; } if (txtlastdatefrom.MaskCompleted) { checkBox1.Checked = false; SQL = SQL + "lastdate>=N'" + txtlastdatefrom.Text.Trim() + "'AND "; check = true; } if (txtlastdateto.MaskCompleted) { checkBox1.Checked = false; SQL = SQL + "lastdate<=N'" + txtlastdateto.Text.Trim() + "'AND "; check = true; } if (checkBox1.Checked) { SQL = SQL + "date=N'" + cur_date.Trim() + "'AND "; check = true; } if (check == true) { SQL = SQL.Remove(SQL.Length - 4); } ghabz rm = new ghabz(); DataTable dt = new DataTable(); dt = rm.Search(SQL); grdDataViewer.DataSource = dt; //} //catch (Exception) //{ // MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!"); // txtname.Text = ""; //} }