protected void Button1_Click(object sender, EventArgs e) { List <InventoryReports.CardOfCategory> lcard = new List <InventoryReports.CardOfCategory>(); InventoryReports inv = new InventoryReports(); lcard = coc.imports(drpitems.SelectedValue, DateTime.Parse(txtfrom.Text, CultureInfo.CreateSpecificCulture("ar-EG")), DateTime.Parse(txtto.Text, CultureInfo.CreateSpecificCulture("ar-EG"))); GridView1.DataSource = lcard; GridView1.DataBind(); if (lcard.Count > 0) { coc = inv.Card_CalcQuntity(lcard); GridView1.FooterRow.Cells[1].Text = coc.imquantity.ToString(); GridView1.FooterRow.Cells[2].Text = coc.exquantity.ToString(); GridView1.FooterRow.Cells[0].Text = "اجماليات"; } }
private void ExportAsBtn_Click(object sender, EventArgs e) { int GeneralNumber = -1; if (int.TryParse(RefNumberTxtBox.Text, out GeneralNumber)) { /*OK DO NOTHING*/ } else { MessageBox.Show("Please Select Reference Number by clicking on the desired row", MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } /* if (ExportAsComboBox.Text == ExportAsComboBox.Items[0].ToString())/*PDF*/ /* { * * } * else if (ExportAsComboBox.Text == ExportAsComboBox.Items[1].ToString())/*Excel*/ /*{ * * } * else * { * MessageBox.Show("Please Select Report Type", MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * }*/ string SaveAsPath = "", ExportPath = ""; bool ExportToPdf = false, ExportToExcel = false; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "PDF file|*.pdf|Excel Sheet|*.xls"; saveFileDialog1.Title = "Save Report (A4)"; saveFileDialog1.FileName = "Adjust Inventory Report" + DateTime.Now.ToShortDateString(); saveFileDialog1.FileName = saveFileDialog1.FileName.ToString().Replace(@"/", "-"); saveFileDialog1.FileName = saveFileDialog1.FileName.ToString().Replace(@"\\", "-"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { SaveAsPath = saveFileDialog1.FileName; switch (saveFileDialog1.FilterIndex) { case 1: ExportToPdf = true; ExportPath = SaveAsPath; break; case 2: //THIS IS ONLY EXCEL ExportToExcel = true; ExportPath = SaveAsPath; break; } } bool retval = false; if (ExportToPdf) { retval = InventoryReports.InventoryAdjustReport(GeneralNumber, true, false, false, true, false, ExportPath, false); } else if (ExportToExcel) { retval = InventoryReports.InventoryAdjustReport(GeneralNumber, true, false, false, false, true, ExportPath, false); } if (retval) { if (ExportToPdf || ExportToExcel) { Process.Start(ExportPath); } } else { MessageBox.Show(MsgTxt.NoDataTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand); } }