private void SetCriteria() { DataTable dt = MyUtil.ExecuteReader("select distinct tahun from m_penjualan order by tahun desc"); cboYear.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { cboYear.Items.Add(dt.Rows[0][0].ToString()); } }
private void txtId_Leave(object sender, EventArgs e) { if (txtId.Text.Trim().Length > 0) { this.UseWaitCursor = true; try { string sql = String.Format("SELECT * FROM m_barang where id={0}", txtId.Text.Trim()); DataTable dt = MyUtil.ExecuteReader(sql); if (dt.Rows.Count > 0) { flag = 1;//update txtId.ReadOnly = true; txtNama.Focus(); txtNama.Text = dt.Rows[0][1].ToString(); txtBeli.Text = MyUtil.GetFormatNumber(dt.Rows[0][2].ToString()); txtJual.Text = MyUtil.GetFormatNumber(dt.Rows[0][3].ToString()); txtSatuan.Text = dt.Rows[0][4].ToString(); txtBerat.Text = dt.Rows[0][5].ToString(); string unit = dt.Rows[0][6].ToString(); if (unit.ToLower() == "gram") { cboUnit.SelectedIndex = 0; } else { cboUnit.SelectedIndex = 1; } string gbr1 = dt.Rows[0][8].ToString(); txtGbr1.Text = (File.Exists(gbr1) || gbr1 == String.Empty) ? gbr1 : MyUtil.IMG_UPDATE; string gbr2 = dt.Rows[0][9].ToString(); txtGbr2.Text = (File.Exists(gbr2) || gbr2 == String.Empty) ? gbr2 : MyUtil.IMG_UPDATE; string gbr3 = dt.Rows[0][10].ToString(); txtGbr3.Text = (File.Exists(gbr3) || gbr3 == String.Empty) ? gbr3 : MyUtil.IMG_UPDATE; string gbr4 = dt.Rows[0][11].ToString(); txtGbr4.Text = (File.Exists(gbr4) || gbr4 == String.Empty) ? gbr4 : MyUtil.IMG_UPDATE; txtKet.Text = dt.Rows[0][7].ToString() + dt.Rows[0][12].ToString() + dt.Rows[0][13].ToString() + dt.Rows[0][14].ToString(); } else { flag = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Find Id", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.UseWaitCursor = false; } }
private void btnShow_Click(object sender, EventArgs e) { try { if (cboYear.SelectedIndex <= -1) { MessageBox.Show("Pilih criteria tahun terlebih dahulu"); return; } string myAppPath = Path.GetDirectoryName(Application.ExecutablePath); rpt.ProcessingMode = ProcessingMode.Local; LocalReport localReport = rpt.LocalReport; localReport.EnableExternalImages = true; localReport.ReportPath = @"REPORT\RptPenjualan.rdlc"; //String.Format(@"{0}\{1}\{2}", myAppPath, Properties.Settings.Default.report_path,"RptBarang.rdlc"); string sql = String.Format("SELECT * FROM m_penjualan WHERE tahun='{0}' order by tgl", cboYear.SelectedItem.ToString()); DataSet dstPenjualan = MyUtil.ExecuteReader(sql, "dstPenjualan", "m_penjualan"); ReportDataSource dsPenjualan = new ReportDataSource("dsPenjualan"); dsPenjualan.Value = dstPenjualan.Tables["m_penjualan"]; localReport.DataSources.Clear(); localReport.DataSources.Add(dsPenjualan); ReportParameter prmImage = new ReportParameter(); prmImage.Name = "ImagePath"; prmImage.Values.Add(String.Format(@"{0}\{1}", myAppPath, Properties.Settings.Default.image_path)); ReportParameter prmYear = new ReportParameter(); prmYear.Name = "Year"; prmYear.Values.Add(cboYear.SelectedItem.ToString()); localReport.SetParameters(new ReportParameter[] { prmImage, prmYear }); localReport.DisplayName = "Penjualan"; rpt.RefreshReport(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Report", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnShow_Click(object sender, EventArgs e) { try { string myAppPath = Path.GetDirectoryName(Application.ExecutablePath); rpt.ProcessingMode = ProcessingMode.Local; LocalReport localReport = rpt.LocalReport; localReport.EnableExternalImages = true; localReport.ReportPath = @"REPORT\RptBarang.rdlc"; //String.Format(@"{0}\{1}\{2}", myAppPath, Properties.Settings.Default.report_path,"RptBarang.rdlc"); DataSet dstBarang = MyUtil.ExecuteReader("SELECT * FROM m_barang order by nama", "dstBarang", "m_barang"); ReportDataSource dsBarang = new ReportDataSource("dsBarang"); dsBarang.Value = dstBarang.Tables["m_barang"]; localReport.DataSources.Clear(); localReport.DataSources.Add(dsBarang); ReportParameter prmImage = new ReportParameter(); prmImage.Name = "ImagePath"; prmImage.Values.Add(String.Format(@"{0}\{1}", myAppPath, Properties.Settings.Default.image_path)); ReportParameter prmComplete = new ReportParameter(); prmComplete.Name = "chkAll"; prmComplete.Values.Add(chkAll.Checked.ToString()); localReport.SetParameters(new ReportParameter[] { prmImage, prmComplete }); localReport.DisplayName = "PriceList"; rpt.RefreshReport(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Report", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cboBarang_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cbo = (ComboBox)sender; if (cbo.SelectedValue == null) { return; } int idBarang; bool isInt = int.TryParse(cbo.SelectedValue.ToString(), out idBarang); if (!isInt) { return; } string sql = String.Format("SELECT nama,harga_jual FROM m_barang where id={0}", idBarang); DataTable dt = MyUtil.ExecuteReader(sql); object objRow = dgv.CurrentRow.Index; if (objRow != null && dt.Rows.Count > 0) { int rowPos = (int)objRow; string nama = dt.Rows[0][0].ToString(); int harga = (int)dt.Rows[0][1]; dgv[3, rowPos].Value = nama; dgv[2, rowPos].Value = harga; string strQty = dgv[6, rowPos].Value.ToString(); if (strQty == String.Empty) { strQty = "1"; dgv[6, rowPos].Value = strQty; } SetTotal(harga, Int32.Parse(strQty), rowPos); } }