Parameters not reflect Panel in stimulsoft (C#) - c#

showing parameters panel the report.
I do not want show.
(source: picofile.com)
My Code is:
StiReport sr = new StiReport();
sr.Load(ClsVariable.Address + "ReportCustomerBuy.mrt");
sr.Dictionary.Variables["Ccode"].Value = txtCode.Text;
sr.Dictionary.Variables["Cname"].Value = txtName.Text;
sr.Dictionary.Variables["Ctel"].Value = txtTel.Text;
sr.Dictionary.Variables["Caddress"].Value = txtAddress.Text;
sr.Dictionary.Variables["Cfathername"].Value = txtFatherName.Text;
sr.Dictionary.Variables["Cdate"].Value = txtDate.Text;
sr.Dictionary.Variables["CPay"].Value = lblGivePrice.Text;
sr.Dictionary.Variables["CHesabK"].Value = lblPriceKK.Text;
sr.Dictionary.Variables["CBedehkar"].Value = s;
sr.Show();

Disable the request from user property
sr.Dictionary.Variables["Ccode"].RequestFromUser = false;

Related

Can not print on Single Page dgvprinter c#

There are 9 columns in datagridview when I print using dgvprinter it prints 7 columns on 1 page and other 2 on a new page. I want to print on a single page anybody helps me?
Note: There is an image on datagridview.
Here is code:
DGVPrinter printer = new DGVPrinter();
printer.Title = "Test";
printer.SubTitle = "Outgoing Stocks";
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "System generated file";
printer.FooterSpacing = 15;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.printDocument.DefaultPageSettings.Landscape = true;
printer.RowHeight = DGVPrinter.RowHeightSetting.CellHeight;
printer.PrintDataGridView(itemdata_datagridview);

DataGridView drawing shows black regions

I have been developing an application using winforms c# .net 4.0.
this application use datagridview and i add combobox + textbox to the datagridview.
During binddata and resizing actions, a black rectangle will draw in the bottom portion of the datagridview.
see the image of the problems
it works perfectly on standard DPI, but problem on the high DPI.
here is the some of my code to binddata and resizing.
using (Class1.Connection = new OleDbConnection(Class1.ConnString))
{
string sql1 = "SELECT tbAuditDetails.AuditNo, tbAuditQuestions.AutoSubcontent, tbAuditQuestions.AutoID, tbAuditQuestions.Questions, tbScore.Description, tbAuditDetails.QuestionID, tbAuditQuestions.QuestAutoID, tbAuditDetails.ScoreID, tbScore.Score, tbAuditQuestions.SubContentID, tbAuditDetails.ProfileID, tbAuditDetails.ScoreRanges, tbAuditDetails.Comments FROM (tbAuditDetails INNER JOIN tbAuditQuestions ON tbAuditDetails.QuestionID = tbAuditQuestions.QuestionID) INNER JOIN tbScore ON tbAuditDetails.ScoreID = tbScore.ScoreID WHERE (([tbAuditDetails.AuditNo] = " + Class1.detailsauditno + ") AND ([tbAuditQuestions.AutoSubcontent] = '" + newautosubcontentid + "') AND ([tbAuditDetails.ProfileID] = " + proid + ")) ORDER BY [tbAuditQuestions.QuestAutoID], [tbAuditDetails.QuestionID]";
Class1.Connection.Open();
oleCommand = new OleDbCommand(sql1, Class1.Connection);
oleAdapter = new OleDbDataAdapter(oleCommand);
oleBuilder = new OleDbCommandBuilder(oleAdapter);
oleDs = new DataSet();
oleAdapter.Fill(oleDs, "tbAuditDetails");
oleTable = oleDs.Tables["tbAuditDetails"];
Class1.Connection.Close();
dataGridView1.DataSource = oleDs.Tables["tbAuditDetails"];
//SET DATAGRIDVIEW
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[4].Visible = false;
dataGridView1.Columns[5].Visible = false;
dataGridView1.Columns[6].Visible = false;
dataGridView1.Columns[7].Visible = false;
dataGridView1.Columns[8].Visible = false;
dataGridView1.Columns[9].Visible = false;
dataGridView1.Columns[10].Visible = false;
dataGridView1.Columns[1].HeaderText = " ";
dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[1].Width = 40;
dataGridView1.Columns[2].HeaderText = "ID";
dataGridView1.Columns[2].Width = 40;
dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[2].ReadOnly = true;
dataGridView1.Columns[3].Width = 600;
dataGridView1.Columns[3].ReadOnly = true;
dataGridView1.Columns[3].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dataGridView1.Columns[11].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[11].HeaderText = "Score";
dataGridView1.Columns[12].Width = 220;
for (int iii = 0; iii < dataGridView1.Rows.Count; iii++)
{
DataGridViewComboBoxCell ComboBoxCell2 = new DataGridViewComboBoxCell();
ComboBoxCell2.Items.Add("0");
ComboBoxCell2.Items.Add("10");
ComboBoxCell2.Items.Add("20");
ComboBoxCell2.Items.Add("30");
ComboBoxCell2.Items.Add("40");
ComboBoxCell2.Items.Add("50");
ComboBoxCell2.Items.Add("60");
ComboBoxCell2.Items.Add("70");
ComboBoxCell2.Items.Add("80");
ComboBoxCell2.Items.Add("90");
ComboBoxCell2.Items.Add("100");
//ComboBoxCell.Items.AddRange(new string[] { "YES", "SOME", "NO", "N/A" });
ComboBoxCell2.FlatStyle = FlatStyle.Standard;
this.dataGridView1[11, iii] = ComboBoxCell2;
ComboBoxCell2.Dispose();
}
}
Any suggestions?
I don't know this is the right solution or not...
BUT, it fix my problem.
Here :
Right click on the .exe program (after you build) and Disable HIGH DPI

how to create dynamic Required field Validator

I have generated an array of required field validators using following code:
Panel[] divMain = new Panel[22];
DropDownList[] gender = new DropDownList[22];
TextBox[] txtFirstName = new TextBox[22];
TextBox[] txtMiddleName = new TextBox[22];
TextBox[] txtLastName = new TextBox[22];
TextBox[] txtAge = new TextBox[22];
RequiredFieldValidator[] req = new RequiredFieldValidator[30];
and i am creating some dynamic controls using following code:
for (int i = 0; i < noOfad - 1; i++)
{
HtmlGenericControl p = new HtmlGenericControl("p");
HtmlGenericControl strong = new HtmlGenericControl("strong");
strong.InnerText = "Adult" + Convert.ToString(i + 2);
p.Controls.Add(strong);
divAdultMoreForm.Controls.Add(p);
Panel div = new Panel();
HtmlGenericControl p1 = new HtmlGenericControl("p");
p1.InnerHtml = "<span><strong>Full Name (As per Valid Govt Id Proof valid )</strong></span> <span><strong style=' margin-left: 549px;'>Age(in Years 18 +) </strong></span>";
div.Controls.Add(p1);
HtmlGenericControl p2 = new HtmlGenericControl("p");
gender[i] = new DropDownList();
gender[i].Items.Add(new ListItem("Title", "0"));
gender[i].Items.Add(new ListItem("Mr.", "1"));
gender[i].Items.Add(new ListItem("Mrs.", "2"));
gender[i].Items.Add(new ListItem("Ms.", "3"));
gender[i].CssClass = "txt";
p2.Controls.Add(gender[i]);
txtFirstName[i] = new TextBox();
txtFirstName[i].Attributes.Add("placeholder", "First Name");
txtFirstName[i].CssClass = "txt input";
txtFirstName[i].ID = "txtFirstName" + Convert.ToString(i);
req[i].ControlToValidate = txtFirstName[i].ID;//Object refrence not set to an instance ofo an object
req[i].ForeColor = System.Drawing.Color.Red;
req[i].ErrorMessage = "*";
txtFirstName[i].CssClass = "input txt";
txtMiddleName[i] = new TextBox();
txtMiddleName[i].Attributes.Add("placeholder", "Middle Name");
txtMiddleName[i].CssClass = "txt input";
txtMiddleName[i].CssClass = "input txt";
txtMiddleName[i].ID = "txtMiddleName" + Convert.ToString(i);
txtLastName[i] = new TextBox();
txtLastName[i].Attributes.Add("placeholder", "Last Name");
txtLastName[i].CssClass = "txt input";
txtLastName[i].CssClass = "input txt";
txtLastName[i].ID = "txtLastName" + Convert.ToString(i);
txtAge[i] = new TextBox();
txtAge[i].Attributes.Add("placeholder", "Enter Age");
txtAge[i].CssClass = "txt";
p2.Controls.Add(txtFirstName[i]);
p2.Controls.Add(txtMiddleName[i]);
p2.Controls.Add(txtLastName[i]);
p2.Controls.Add(txtAge[i]);
div.Controls.Add(p2);
divAdultMoreForm.Controls.Add(div);
}
But when i am assigning the control to validate to the validator req[i] then there comes an error Object reference not set to an instance of an object.
Can not understand why this problem is occuring.
Any help to correct my code!
Thanks
This is due to the fact that you forgot to initialize the RequiredFieldValidator array object. This seems to be missing from your code :
req[i] = new RequiredFieldValidator();
After this you can play with its properties.
Hope this clears it.

Call the SSRS report in button click and need to get the output as PDF file

I had an grid view where I had placed an link button to print an report. In this button click event I need to call the SSRS report and need to get the output as PDF file.
I had used this below code,the code is running fine, but I'm unable to see the prompt to open/save pdf file.
protected void btnAuthenticateAndPrint_Click(object sender, EventArgs args)
{
try
{
//Getting Values from grid
LinkButton lb = (LinkButton)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
Label lbOrderID = row.FindControl("lbOrderID") as Label;
int OrderId = Convert.ToInt32(lbOrderID.Text);
da = new SqlDataAdapter("Get_PODetails", con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("#MPDI_ID", OrderId);
ds = new DataSet();
da.Fill(ds, "PO");
if (ds.Tables["PO"].Rows.Count > 0)
{
lblPOId.Text=ds.Tables["PO"].Rows[0]["MPDI_ID"].ToString();
lblVendid.Text = ds.Tables["PO"].Rows[0]["MVDI_ID"].ToString();
lblBranch.Text = ds.Tables["PO"].Rows[0]["MBRI_ID"].ToString();
lblDate.Text = Convert.ToDateTime(ds.Tables["PO"].Rows[0]["MPDI_Date"]).ToString("dd-MM-yyyy");
}
//SSRS Report Print
rs = new RSWebService.ReportingService2005();
rsExec = new REWebService.ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
rsExec.Url = "http://localhost/ReportServer/ReportExecution2005.asmx";
byte[] Sendresults = null;
byte[] bytes = null;
string historyID = null;
string deviceInfo = #"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
string format = "PDF";
string encoding = null;
string mimeType = null;
string extension = null;
REWebService.Warning[] warnings = null;
string[] streamIDs = null;
string _reportName = #"/FIMO GOF Assets Reports/PURCHASE ORDER";
REWebService.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID);
REWebService.ParameterValue[] parameters = new REWebService.ParameterValue[4];
parameters[0] = new REWebService.ParameterValue();
parameters[0].Name = "MVDI_ID";
parameters[0].Value = lblVendid.Text;
parameters[1] = new REWebService.ParameterValue();
parameters[1].Name = "MBRI_ID";
parameters[1].Value = lblBranch.Text;
parameters[2] = new REWebService.ParameterValue();
parameters[2].Name = "MPDI_Date";
parameters[2].Value = lblDate.Text;
parameters[3] = new REWebService.ParameterValue();
parameters[3].Name = "ReportParameter1";
parameters[3].Value = lblPOId.Text;
rsExec.SetExecutionParameters(parameters, "en-us");
Sendresults = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
MemoryStream ms = new MemoryStream(Sendresults);
//To create a PDF
if (format == "PDF")
{
Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "inline;filename=output.pdf");
Response.AddHeader("Content-Length", Sendresults.Length.ToString());
}
Response.OutputStream.Write(Sendresults, 0, Sendresults.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
}
catch(Exception Ex)
{
throw Ex;
}
}
You can use URL access, as described here: http://msdn.microsoft.com/en-us/library/ms154040(v=sql.105).aspx
http://<Server Name>/reportserver?/Sales/YearlySalesSummary&rs:Format=PDF&rs:Command=Render

Add textbox via dynamic imagebutton in a panel

I have a problem I seem to stumble over all the time, I have a Drop Down box and you can select a number which creates x number of textboxes with images buttons its for a survey it the image buttons are used to create "Sub-Answers" so they can have answers to answers so my question is I need to when they hit the image button to create a textbox under the orginal textbox here is the code.
for (Int32 i = 1; i <= NumberOfAnwsers; i++)
{
Literal l1 = new Literal();
l1.Text = "<tr><td>Answer " + i + " text.</td><td>";
TextBox tb = new TextBox();
tb.ID = "TextBoxAnswer" + i;
tb.EnableViewState = false;
tb.Width = 300;
Literal l3 = new Literal();
l3.Text = "</td><td>";
Literal l2 = new Literal();
l2.Text = "</td></tr>";
RadColorPicker CPI = new RadColorPicker();
CPI.PaletteModes = PaletteModes.WebPalette;
CPI.ID = "RadColorPicker" + i;
CPI.ShowIcon = true;
CPI.SelectedColor = System.Drawing.Color.Black;
ImageButton IBVideo = new ImageButton();
IBVideo.ID = "IBVideo" + i;
IBVideo.ImageUrl = "/images/video-icon.jpg";
IBVideo.ToolTip = "Add Video";
IBVideo.Height = 20;
IBVideo.Width = 20;
ImageButton IBAdd = new ImageButton();
IBAdd.ID = "IBAdd" + i;
IBAdd.ImageUrl = "/images/add-icon.png";
IBAdd.ToolTip = "Add Sub-Answers";
//IBAdd.OnClientClick = "showDialog(" + i + ");return false;";
IBAdd.Height = 20;
IBAdd.Width = 20;
//Add Textbox
PanelAnswersToQuestions.Controls.Add(l1);
PanelAnswersToQuestions.Controls.Add(tb);
PanelAnswersToQuestions.Controls.Add(l3);
PanelAnswersToQuestions.Controls.Add(CPI);
PanelAnswersToQuestions.Controls.Add(IBVideo);
PanelAnswersToQuestions.Controls.Add(IBAdd);
PanelAnswersToQuestions.Controls.Add(l2);
}
As you can see I just add controls to the panel, I need to know when that ImageBUtton is hit I can add a Textbox and in this case it could be more then just one textbox to it.
I hope this is clear but for some reason I dont think it is ... sorry.
I have added a radwindow and poping that up sending the Data to the partent via javascript the which created a new problem for me, I can not in javascript seem to find the dynamicly created hiddenfield
function OnClientClose(radWindow) {
var oWnd = $find("<%=RadWindowAddSubAnswer.ClientID%>");
var SubAnswerValues = oWnd.get_contentFrame().contentWindow.document.forms(0).HiddenFieldSubAnswers.value;
alert(SubAnswerValues);
var AnswerID = oWnd.get_contentFrame().contentWindow.document.forms(0).HiddenFieldAnswerID.value;
alert(AnswerID);
var HiddenName = "HiddenFieldSubAnswers" + AnswerID;
alert(HiddenName);
document.getElementById(HiddenName).value = SubAnswerValues;
$get("DivSubAnswers" + AnswerID).innerHTML = SubAnswerValues;
}
The "document.getElementById(HiddenName).value = SubAnswerValues;" seems to never be found, I also tried $get(HiddenName).value = SubAnswerValues; that does not seem to work either both come back as null as for the code behind its:
HiddenField HFSubAnswers = new HiddenField();
HFSubAnswers.ID = "HiddenFieldSubAnswers" + i;
HFSubAnswers.Value = "0";
Im not sure if I got your question right but if you need to dynamically add controls on a Page here is what I can say.
Before adding your control I guess you need to find the control where you need to add it on, Add the control then assign the properties.
PlaceHolder myPlaceHolder = (PlaceHolder)Page.FindControl("PlaceHolder1");
myPlaceHolder.Controls.Add(myButton);
myButton.Text = "Hello World";
For a more detailed expalnation go here http://anyrest.wordpress.com/2010/04/06/dynamically-removing-controls-in-a-parent-page-from-a-child-control/

Categories

Resources