private void frmPrintPreview_Load(object sender, EventArgs e) { objFLRep.objCompany = objBLFD.ObjCompany; objFl_Gen_Inv.objCompany = objBLFD.ObjCompany; if (flgDocorReport) { dsetRep = objFLRep.Get_Rep_Documents(ObjBLFD); if (dsetRep != null && dsetRep.Tables[0].Rows.Count != 0) { if (dsetRep.Tables[0].Rows.Count == 1) { if (flgPreviewOrSendMail) { frmPrint objfrmPrint = new frmPrint(true); objfrmPrint.ObjBLFD = ObjBLFD; objfrmPrint.tran_cd = ObjBLFD.Code; objfrmPrint.tran_id = ObjBLFD.HTMAIN[ObjBLFD.Primary_id].ToString(); objfrmPrint.sp_name = dsetRep.Tables[0].Rows[0]["sp_nm"].ToString().Trim(); objfrmPrint.rep_nm = dsetRep.Tables[0].Rows[0]["rep_nm"].ToString().Trim(); objfrmPrint.rep_nmshow = dsetRep.Tables[0].Rows[0]["desc"].ToString().Trim(); // objfrmPrint.objComp = objBLFD.ObjCompany; objfrmPrint.Show(); this.Close(); } else { SendMail(); } } else { GroupBox grpbxreports = new GroupBox(); grpbxreports.Text = "Reports Details"; dgv.Name = "dgvRep"; dgv.Dock = DockStyle.Fill; dgv.RowHeadersVisible = false; dgv.AllowUserToAddRows = false; DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); chkcol.HeaderText = "Select"; chkcol.Name = "sel"; dgv.Columns.Add(chkcol); dgv.Columns["sel"].Width = ctrlwid * 22 / 100; DataGridViewTextBoxColumn txtcol = new DataGridViewTextBoxColumn(); txtcol.HeaderText = "Report Name"; txtcol.Name = "rep_desc"; dgv.Columns.Add(txtcol); dgv.Columns["rep_desc"].Width = ctrlwid * 75 / 100; DataGridViewTextBoxColumn txtcol1 = new DataGridViewTextBoxColumn(); txtcol1.HeaderText = "Procedure Name"; txtcol1.Name = "sp_nm"; dgv.Columns.Add(txtcol1); dgv.Columns["sp_nm"].Visible = false; DataGridViewTextBoxColumn txtcol2 = new DataGridViewTextBoxColumn(); txtcol2.HeaderText = "Report Name"; txtcol2.Name = "rep_nm"; dgv.Columns.Add(txtcol2); dgv.Columns["rep_nm"].Visible = false; dgv.Rows.Clear(); int i = 0; foreach (DataRow row in dsetRep.Tables[0].Rows) { dgv.Rows.Add(1); dgv.Rows[i].Cells[1].Value = row["desc"].ToString(); dgv.Rows[i].Cells[2].Value = row["sp_nm"].ToString(); dgv.Rows[i].Cells[3].Value = row["rep_nm"].ToString(); i++; } //dgv.Bounds = new Rectangle(5, hgt + 5, (ctrlwid), ctrlhgt * 75 / 100); grpbxreports.Bounds = new Rectangle(5, hgt + 5, (ctrlwid) - 10, ctrlhgt / 2); hgt += ctrlhgt / 2 + (ctrlhgt * 5 / 100); grpbxreports.Controls.Add(dgv); // dgv.Rows.RemoveAt(dgv.Rows.Count-1); panel1.Controls.Add(grpbxreports); if (objBLFD.Copies_nm != "" && objBLFD.Copies_nm != null) { GroupBox grpbxreports1 = new GroupBox(); grpbxreports1.Text = "Copy Details"; // DataGridView dgv1 = new DataGridView(); dgv1.Name = "dgvRepCopy"; dgv1.Dock = DockStyle.Fill; // dgv1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; //dgv.Height = panel1.Size.Height * 70 / 100; dgv1.RowHeadersVisible = false; dgv1.AllowUserToAddRows = false; DataGridViewCheckBoxColumn chkcol1 = new DataGridViewCheckBoxColumn(); chkcol1.HeaderText = "Select"; chkcol1.Name = "sel"; dgv1.Columns.Add(chkcol1); dgv1.Columns["sel"].Width = ctrlwid * 22 / 100; DataGridViewTextBoxColumn txtcolcopy = new DataGridViewTextBoxColumn(); txtcolcopy.HeaderText = "Copy Name"; txtcolcopy.Name = "copy_nm"; dgv1.Columns.Add(txtcolcopy); dgv1.Columns["copy_nm"].Width = ctrlwid * 75 / 100; dgv1.Rows.Clear(); //DataSet dsetcopy = objFl_Gen_Inv.GET_TBL_VAL("Copy_mast", "", ObjBLFD.ObjCompany.Compid.ToString()); String strCopy = objBLFD.Copies_nm; int j = 0; //foreach (DataRow row in dsetcopy.Tables[0].Rows) //{ // dgv1.Rows.Add(1); // dgv1.Rows[j].Cells[1].Value = row["copy_nm"].ToString(); // j++; //} foreach (String str in strCopy.Split(',')) { dgv1.Rows.Add(1); dgv1.Rows[j].Cells[1].Value = str; j++; } dgv1.CellContentClick += new DataGridViewCellEventHandler(dgv1_CellContent_click); grpbxreports1.Bounds = new Rectangle(5, hgt, (ctrlwid) - 10, ctrlhgt / 2); hgt += ctrlhgt / 2 + (ctrlhgt * 5 / 100); grpbxreports1.Controls.Add(dgv1); panel1.Controls.Add(grpbxreports1); } Button btn = new Button(); btn.Name = "Proceed"; btn.Text = "&Proceed"; btn.Click += new EventHandler(btnProceed_Click); btn.Bounds = new Rectangle((ctrlwid / 2) * 15 / 100, hgt, (ctrlwid / 2) * 70 / 100, ctrlhgt * 10 / 100); // btn.TextAlign = ContentAlignment.MiddleCenter; this.panel1.Controls.Add(btn); Button btn1 = new Button(); btn1.Name = "Cancel"; btn1.Text = "&Cancel"; btn1.Click += new EventHandler(btnCancel_Click); btn1.Bounds = new Rectangle(((ctrlwid / 2) * 15 / 100) + (ctrlwid / 2), hgt, (ctrlwid / 2) * 70 / 100, ctrlhgt * 10 / 100); hgt += ctrlhgt * 15 / 100; // btn1.TextAlign = ContentAlignment.MiddleCenter; this.panel1.Controls.Add(btn1); // this.panel1.Height = hgt; this.Width = ctrlwid; this.Height = hgt; } } else { AutoClosingMessageBox.Show("No documents exist", "Error", 3000); this.Close(); } } else { frmPrint objfrmPrint = new frmPrint(false); objfrmPrint.ObjBLFD = ObjBLFD; objfrmPrint.sp_name = HTFilter["sp_nm"].ToString(); objfrmPrint.rep_nm = HTFilter["rep_nm"].ToString(); objfrmPrint.rep_nmshow = HTFilter["rep_gr"].ToString(); objfrmPrint.HTFilter = this.HTFilter; // objfrmPrint.objComp = objBLFD.ObjCompany; objfrmPrint.Show(); this.Close(); } ucToolBar1.Width1 = this.Width; this.Height = hgt; AddThemesToTitleBar((Form)this, ucToolBar1, objBLFD, "Report"); ucToolBar1.Titlebar = "Print Preview"; }
private void btnProceed_Click(object sender, EventArgs e) { if (flgPreviewOrSendMail) { foreach (Control c in panel1.Controls) { if (c is GroupBox) { foreach (Control c1 in ((GroupBox)c).Controls) { if (c1 is DataGridView) { foreach (DataGridViewRow r in ((DataGridView)c1).Rows) { if (((DataGridView)c1).Columns.Count != 2 && !flgCopy && r.Cells["sel"].Value != null && bool.Parse(r.Cells["sel"].Value.ToString())) { objBLFD.ObjCompany.Copy_nm = "Original For Buyer"; frmPrint objfrmPrint = new frmPrint(true); objfrmPrint.ObjBLFD = ObjBLFD; objfrmPrint.tran_cd = ObjBLFD.Code; objfrmPrint.tran_id = ObjBLFD.HTMAIN[ObjBLFD.Primary_id].ToString(); objfrmPrint.sp_name = r.Cells["sp_nm"].Value.ToString(); objfrmPrint.rep_nm = r.Cells["rep_nm"].Value.ToString(); objfrmPrint.rep_nmshow = r.Cells["rep_desc"].Value.ToString(); // objfrmPrint.objComp = objBLFD.ObjCompany; objfrmPrint.Show(); } else { if (((DataGridView)c1).Columns.Count == 2 && r.Cells["sel"].Value != null && bool.Parse(r.Cells["sel"].Value.ToString())) { foreach (DataGridViewRow row in dgv.Rows) { if (row.Cells["sel"].Value != null && bool.Parse(row.Cells["sel"].Value.ToString())) { objBLFD.ObjCompany.Copy_nm = r.Cells["copy_nm"].Value.ToString(); frmPrint objfrmPrint = new frmPrint(true); objfrmPrint.ObjBLFD = ObjBLFD; objfrmPrint.tran_cd = ObjBLFD.Code; objfrmPrint.tran_id = ObjBLFD.HTMAIN[ObjBLFD.Primary_id].ToString(); objfrmPrint.sp_name = row.Cells["sp_nm"].Value.ToString(); objfrmPrint.rep_nm = row.Cells["rep_nm"].Value.ToString(); objfrmPrint.rep_nmshow = row.Cells["rep_desc"].Value.ToString(); // objfrmPrint.objComp = objBLFD.ObjCompany; objfrmPrint.Show(); } } } } } } } } } } else { SendMail();//1.0 } this.Close(); }