DevExpress grid not getting inside detail row - c#

Please find the following line in default.aspx.cs
ASPxGridView grid = gvPatient.FindDetailRowTemplateControl(index, "gvOrder") as ASPxGridView;
Its not getting the gvOrder Aspxgridview inside detail row template of gvPatient.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ADLPRO2MODEL;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxEditors;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void gvOrder_BeforePerformDataSelect(object sender, EventArgs e)
{
Session["PatientNo"] = (sender as ASPxGridView).GetMasterRowKeyValue();
}
protected void btnSave_Click(object sender, EventArgs e)
{
// string key = (string)gvPatient.GetMasterRowKeyValue();
decimal key = (decimal)Session["PatientNo"];
int index = gvPatient.FindVisibleIndexByKeyValue(key);
ASPxGridView grid = gvPatient.FindDetailRowTemplateControl(index, "gvOrder") as ASPxGridView;
ASPxMemo tbNote = gvPatient.FindControl("tbNote") as ASPxMemo;
ASPxLabel lblMsg = gvPatient.FindControl("lblMsg") as ASPxLabel;
int patientNo = Convert.ToInt32(grid.GetSelectedFieldValues("PAT_NUMBER")[index]);
int orderKey = Convert.ToInt32(grid.GetSelectedFieldValues("ORDER_KEY")[index]);
ADLPRO2ENTITIES context = new ADLPRO2ENTITIES();
ORD_D_PHA_RECOMMEND obj = context.ORD_D_PHA_RECOMMEND.FirstOrDefault(i => i.ORDER_KEY == orderKey && i.PAT_NUMBER == patientNo);
bool? b = null;
if (obj != null)
{
obj.Cont = b;
if (tbNote.Text.Trim() != string.Empty)
{
obj.Note = tbNote.Text.Trim();
}
}
else
{
obj = new ORD_D_PHA_RECOMMEND();
obj.Cont = b;
if (tbNote.Text.Trim() != string.Empty)
{
obj.Note = tbNote.Text.Trim();
}
obj.ORDER_KEY = orderKey;
obj.PAT_NUMBER = patientNo;
context.AddToORD_D_PHA_RECOMMEND(obj);
}
context.SaveChanges();
tbNote.Text = string.Empty;
lblMsg.Text = "Saved";
}
}

Related

Perform web searches through C # Windows forms

I'm trying to realize web searches to get the title of websites on a Google search.
I got a code that works well on other sites, but using Google I got duplicated results.
I have tried and tried, but I can't see where is the mistake.
Code simplified:
public partial class Form1 : Form
{
WebBrowser navegador = new WebBrowser();
private void Form1_Load(object sender, EventArgs e)
{
navegador.ScriptErrorsSuppressed = true;
navegador.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this.datos);
}
private void datos(object sender, EventArgs e)
{
try
{
foreach (HtmlElement etiqueta in navegador.Document.All)
{
if (etiqueta.GetAttribute("classname").Contains("LC20lb DKV0Md"))
{
listBox1.Items.Add(etiqueta.InnerText);
}
}
}
catch (Exception exception) { }
}
private void function(object sender, EventArgs e)
{
/// string query = "https://google.com/search?q=" + query_box.Text;
navegador.Navigate("https://google.com/search?q=water");
/// this.Text = query;
}
}
Result:
I don't know how google works but you can prevent duplicates like this
if(!listBox1.Items.Contains(etiqueta.InnerText))
listBox1.Items.Add(etiqueta.InnerText);
After a couple of days researching and improving the code I decided to change the list for a table.
In addition, now the searches are not duplicated and are positioned in the table as expected
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SourceDownloader
{
public partial class Form1 : Form
{
strs valor = new strs();
public Form1()
{
InitializeComponent();
}
WebBrowser navegador = new WebBrowser();
private void Form1_Load(object sender, EventArgs e)
{
navegador.ScriptErrorsSuppressed = true;
navegador.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this.datos);
}
private void datos(object sender, EventArgs e)
{
try
{
foreach (HtmlElement etq in navegador.Document.All)
{
if (etq.GetAttribute("classname").Contains("r")) /// LC20lb DKV0Md
{
foreach (HtmlElement a_et in etq.GetElementsByTagName("a"))
{
valor.link = a_et.GetAttribute("href");
}
foreach (HtmlElement t_et in etq.GetElementsByTagName("h3"))
{
valor.tit = t_et.InnerText;
}
bool exist = dataGridView1.Rows.Cast<DataGridViewRow>().Any(row => Convert.ToString(row.Cells["link"].Value) == valor.link);
var s1 = valor.link;
bool b = s1.Contains("google.com");
bool a = s1.Contains("googleusercontent");
if (!exist /* && !b && !a*/)
{
dataGridView1.Rows.Insert(0, valor.tit, valor.link);
}
}
if (etq.GetAttribute("classname").Contains("G0iuSb"))
{
valor.next = etq.GetAttribute("href");
}
}
more_ops.Enabled = true;
}
catch (Exception)
{
}
}
private void function(object sender, EventArgs e)
{
string query = "https://google.com/search?q=" + query_box.Text;
navegador.Navigate(query);
this.Text = query;
}
private void more_ops_Click(object sender, EventArgs e)
{
string query = valor.next;
navegador.Navigate(query);
this.Text = query;
}
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
var msg = dataGridView1.CurrentCell.Value;
System.Diagnostics.Process.Start(msg.ToString());
}
catch (Exception)
{
MessageBox.Show("Error");
}
}
private void Enter(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
string texto = query_box.Text;
texto = texto.Replace("\n", "");
query_box.Text = texto;
string query = "https://google.com/search?q=" + query_box.Text;
navegador.Navigate(query);
this.Text = query;
}
}
}
/// global values
class strs
{
private string _link = "N/A";
private string _tit = "N/A";
private string _next = "N/A";
public string tit
{
get
{
return _tit;
}
set
{
_tit = value;
}
}
public string link
{
get
{
return _link;
}
set
{
_link = value;
}
}
public string next
{
get
{
return _next;
}
set
{
_next = value;
}
}
}
}

Button Click URL + String

I am trying to have a click event navigate the webBrowser to a pre-set location + string but I can't seem to get it to work.
My biggest issue is maybe getting the string from one event to the click event?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Ink
{
public partial class inkForm : Form
{
public inkForm()
{
InitializeComponent();
}
string searchlink;
private void searchbutton_Click(object sender, EventArgs e)
{
this.AcceptButton = searchbutton;
int itemrow = -1;
String searchValue = searchtextBox.Text.ToUpper();
if (searchValue != null && searchValue != "")
{
foreach (DataGridViewRow row in inkGridView.Rows)
{
if (row.Cells[1].Value.ToString().Equals(searchValue))
{
itemrow = row.Index;
break;
}
else if (row.Cells[1].Value.ToString().Contains(searchValue) && itemrow == -1)
{
itemrow = row.Index;
}
}
if (itemrow == -1)
{
searchtextBox.BackColor = Color.Red;
}
else
{
searchtextBox.BackColor = Color.White;
inkGridView.Rows[itemrow].Selected = true;
inkGridView.FirstDisplayedScrollingRowIndex = itemrow;
}
}
}
private void inkForm_Load(object sender, EventArgs e)
{
this.hPTableAdapter.Fill(this.inkDataSet.HP);
}
private void updatebutton_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Are you sure you want to update the stock level?", "Message", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
if (dr == DialogResult.Yes)
{
this.hPTableAdapter.Update(inkDataSet.HP);
inkGridView.Refresh();
MessageBox.Show("Record Updated.", "Success!");
}
}
private void inkGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
inkGridView.Columns["tonerInkDataGridViewTextBoxColumn"].ReadOnly = true;
}
private void inkGridView_SelectionChanged(object sender, EventArgs e)
{
if (inkGridView.SelectedCells.Count > 0)
{
int selectedrowindex = inkGridView.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = inkGridView.Rows[selectedrowindex];
string searchlink = Convert.ToString(selectedRow.Cells["tonerInkDataGridViewTextBoxColumn"].Value);
}
}
private void orderbutton_Click(object sender, EventArgs e)
{
string link;
string searchlink = "blahblah";
link = "http://store.tindallsb2b.co.uk/storefront/evolution_ProductResults.html?strSearch=" + searchlink;
webBrowser.Url = new Uri(link);
}
private void urlcheckertextbox_TextChanged(object sender, EventArgs e)
{
urlcheckertextbox.Text = webBrowser.Url.ToString();
}
}
}
When button is clicked, it navigates the domain to a "unknown location" page on the website (The website is not owned by me).
The idea is to click the cell in the DataGridView which is a product code, then click the button which adds the product code to the set url and loads the url+string in the webBrowser.
Your vairable searchlink isn't visible to your orderbutton_Click(). A solution would be to declare the varible searchlink outside of the methods in your class. In fact you are using completely different variables (both named searchlink) inside your methods.
So for example:
class testclass
{
string teststring1 = ""; //visible in both methods
private void testmethod1()
{
string teststring2 = ""; //only visible in this method
teststring1 = "it works!";
}
private void testmethod2()
{
teststring2 = "this won't compile"; //teststring2 is not visible here
teststring1 = "it works, too";
//but what you are doing is:
string teststring2 = ""; //new variable (not related to teststring2 from above)
}
}
And as bkribbs told me this is called a variable scope. Thanks!
For solving your specific problem here is the new code:
string searchlink = "";
private void inkGridView_SelectionChanged(object sender, EventArgs e)
{
if (inkGridView.SelectedCells.Count > 0)
{
int selectedrowindex = inkGridView.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = inkGridView.Rows[selectedrowindex];
searchlink = Convert.ToString(selectedRow.Cells["tonerInkDataGridViewTextBoxColumn"].Value);
}
}
private void orderbutton_Click(object sender, EventArgs e)
{
string link;
link = "http://store.tindallsb2b.co.uk/storefront/evolution_ProductResults.html?strSearch=" + searchlink;
webBrowser.Url = new Uri(link);
}
I hope I got your problem right :)

Usercontrol event firing multiple times asp.net c#

I've got the following code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Testing.Event_Delegate
{
public partial class WebForm1 : System.Web.UI.Page
{
WebUserControl2 QT2;
WebUserControl3 QT3;
DataTable dtQuestionSet;
protected void Page_Init(object sender, EventArgs e)
{
dtQuestionSet = (DataTable)Session["DataTableW"];
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
Session["Counter"] = 0;
Session["QuestionCount"] = 0;
Session["CompletedInsp"] = false;
}
//check to see if the inspection process is complete and display pass\fail and log. Else carry on.
if (Convert.ToBoolean(Session["CompletedInsp"]) == true)
{
//Response.Write("Failed");
ModalPopupExtender2.Show();
return;
}
// all controls need to be rendered every page postback otherwise the rest of the code loses scope.
QT2 = (WebUserControl2)this.LoadControl("WebUserControl2.ascx");
UC2BtnClickEvent.MyEvent2 += new UC2BtnClickEvent.OnMyEvent2(ChecKResult);
QT3 = (WebUserControl3)this.LoadControl("WebUserControl3.ascx");
UC2BtnClickEvent.MyEvent3 += new UC2BtnClickEvent.OnMyEvent3(ChecKResult);
PlaceHolder2.Controls.Add(QT2);
PlaceHolder2.Controls.Add(QT3);
QT2.Visible = false;
QT3.Visible = false;
if (IsPostBack == false)
{
dtQuestionSet = new DataTable();
MakeDataTabledtQuestionSet();
}
else
{
dtQuestionSet = (DataTable)Session["DataTableW"];
}
Session["DataTableW"] = dtQuestionSet;
}
void ChecKResult(object sender, EventArgs e, string strTextBox, string strMyDescription)
{
Label1.Text = "You Answered: - " + strMyDescription;
if (Convert.ToInt32(Session["Counter"]) > Convert.ToInt32(Session["QuestionCount"]))
{
Session["CompletedInsp"] = true;
}
else
{
//carry on with inspection
Session["Counter"] = Convert.ToInt32(Session["Counter"]) + 1;
dtQuestionSet = (DataTable)Session["DataTableW"];
RunInspection();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("WebForm1.aspx");
}
protected void cmdStartInspection_Click(object sender, EventArgs e)
{
Session["Counter"] = 0;
GetQuestions();
}
protected void GetQuestions()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PromptedInspConnectionString"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand("test.GetQuestions", conn);
SqlDataReader dr = null;
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.Add(new SqlParameter("#Block1", cmbBlock1.Text));
dr = cmd.ExecuteReader();
while (dr.Read())
{
DataRow drQuestions = dtQuestionSet.NewRow();
drQuestions["QuestionText"] = dr[1].ToString();
drQuestions["ExpectedResponse"] = dr[2].ToString();
drQuestions["QuestionType"] = dr[3].ToString();
dtQuestionSet.Rows.Add(drQuestions);
}
Session["DataTableW"] = dtQuestionSet;
Session["QuestionCount"] = dtQuestionSet.Rows.Count;
conn.Close();
RunInspection();
}
protected void RunInspection()
{
switch (dtQuestionSet.Rows[Convert.ToInt32(Session["counter"])][2].ToString())
{
case "1":
QT2.QuestionText = dtQuestionSet.Rows[0][0].ToString();//"I'm asking a question 1";
QT2.Visible = true;
break;
case "2":
QT3.QuestionText = dtQuestionSet.Rows[0][0].ToString();//"I'm asking a question 2";
QT3.Visible = true;
break;
}
}
private void MakeDataTabledtQuestionSet()
{
dtQuestionSet.Columns.Add("QuestionText");
dtQuestionSet.Columns.Add("ExpectedResponse");
dtQuestionSet.Columns.Add("QuestionType");
}
}
}
When I click on the button on a usercontrol with the code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Testing.Event_Delegate
{
public partial class WebUserControl2 : System.Web.UI.UserControl
{
string questionAsked;
public string QuestionText
{
set { questionAsked = value; }
get { return questionAsked; }
}
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = QuestionText;
TextBox1.Focus();
}
protected void Button1_Click(object sender, EventArgs e)
{
UC2BtnClickEvent bEvent = new UC2BtnClickEvent();
bEvent.onRefresh2Event3(sender, e, TextBox1.Text, TextBox1.Text );
TextBox1.Text = "";
}
}
}
It runs the procedure CheckResults 3 times on the aspx page when I only need it to run once.
UC2BtnClickEvent.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Testing.Event_Delegate
{
public class UC2BtnClickEvent
{
public delegate void OnMyEvent2(object sender, EventArgs e, string strTextBox, string strMyDescription);
public static event OnMyEvent2 MyEvent2;
public virtual void onRefresh2Event2(object sender, EventArgs e, string strTextBox, string strMyDescription)
{
if (MyEvent2 != null)
{
MyEvent2(sender, e, strTextBox, strMyDescription);
}
}
public delegate void OnMyEvent3(object sender, EventArgs e, string strTextBox, string strMyDescription);
public static event OnMyEvent3 MyEvent3;
public virtual void onRefresh2Event3(object sender, EventArgs e, string strTextBox, string strMyDescription)
{
if (MyEvent3 != null)
{
MyEvent3(sender, e, strTextBox, strMyDescription);
}
}
}
}
What have I done wrong to make this happen please as it should only run once.

TAPI3LIB C#.NET - BasicCallControll.Connect crash

I have a sample code from the MS site, about a TAPI application which creates a call.
The code works. I can actually make a call as well.
Then when I hang up and try again, it crashed on the "connect statement" though I create the object the line before (as per sample code from MS)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TapiSample {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
tapi = new TAPI3Lib.TAPIClass();
tapi.Initialize();
foreach (TAPI3Lib.ITAddress ad in (tapi.Addresses as TAPI3Lib.ITCollection)) {
cbLines.Items.Add(ad.AddressName);
}
tapi.EventFilter = (int)(TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION |
TAPI3Lib.TAPI_EVENT.TE_CALLINFOCHANGE |
TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT |
TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT |
TAPI3Lib.TAPI_EVENT.TE_CALLSTATE |
TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT |
TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS |
TAPI3Lib.TAPI_EVENT.TE_REQUEST);
tapi.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(tapi_ITTAPIEventNotification_Event_Event);
}
TAPI3Lib.TAPIClass tapi = null;
TAPI3Lib.ITAddress line = null;
int cn = 0;
private void button1_Click(object sender, EventArgs e) {
if (line != null) {
line = null;
if (cn != 0) tapi.UnregisterNotifications(cn);
}
foreach (TAPI3Lib.ITAddress ad in (tapi.Addresses as TAPI3Lib.ITCollection)) {
if (ad.AddressName == cbLines.Text) {
line = ad;
break;
}
}
if (line != null) {
cn = tapi.RegisterCallNotifications(line, true, true, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO, 2);
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
if (cn != 0) tapi.UnregisterNotifications(cn);
}
delegate void AddLogDelegate(string text);
private void AddLog(string text) {
if (this.InvokeRequired) {
this.Invoke(new AddLogDelegate(AddLog), new object[] { text });
}
listBox1.Items.Insert(0, text);
}
private void tapi_ITTAPIEventNotification_Event_Event(TAPI3Lib.TAPI_EVENT TapiEvent, object pEvent) {
try {
switch (TapiEvent) {
case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
TAPI3Lib.ITCallNotificationEvent cn = pEvent as TAPI3Lib.ITCallNotificationEvent;
if (cn.Call.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING) {
string c = cn.Call.get_CallInfoString(TAPI3Lib.CALLINFO_STRING.CIS_CALLERIDNUMBER);
AddLog("Call Offering: " + c + " -> " + cn.Call.Address.DialableAddress);
}
break;
}
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e) {
if (line == null) return;
TAPI3Lib.ITBasicCallControl bc = line.CreateCall(teNumber.Text, TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO);
bc.Connect(false); // <!------ CRASH HERE ON 2ND TRY
}
}
}

Transferring from one form to another

So I'm trying to find out and breaking each method while running my codes, and I still can't find why setTempID is always 0, I already assigned a value to it.
Here is my code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
//imports
using DHELTASSys.DataAccess;
using DHELTASSys.Modules;
using DHELTASSys.AuditTrail;
namespace Enrollment
{
public partial class HRLogin : Form
{
HRModuleBL obj = new HRModuleBL();
DHELTASSysAuditTrail audit = new DHELTASSysAuditTrail();
public HRLogin()
{
InitializeComponent();
}
private void txtLogin_Click(object sender, EventArgs e)
{
obj.Emp_id = int.Parse(txtEmpID.Text);
audit.Emp_id = int.Parse(txtEmpID.Text);
obj.Password = txtPassword.Text;
if (obj.AccountEnrollmentLogin().Rows.Count == 0)
{
MessageBox.Show("Username and Password is incorrect!");
}
else if (obj.CheckIfHRManager().Rows.Count == 0)
{
MessageBox.Show("You are not allowed to access this system!");
}
else
{
CreateAccount frm = new CreateAccount();
frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
audit.AddAuditTrail("Has logged in into the Fingerprint Enrollment System.");
frm.setEmpID = int.Parse(txtEmpID.Text);
frm.Show();
this.Hide();
}
}
void frm_FormClosed(object sender, FormClosedEventArgs e)
{
this.Show();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
and here is the other form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
//imports
using DHELTASSys.AuditTrail;
using DHELTASSys.Modules;
namespace Enrollment
{
delegate void Function(); // a simple delegate for marshalling calls from event handlers to the GUI thread
public partial class CreateAccount : Form
{
HRModuleBL obj = new HRModuleBL();
DHELTASSysAuditTrail audit = new DHELTASSysAuditTrail();
private int emp_id;
public int setEmpID
{
set { emp_id = value;}
}
public CreateAccount()
{
InitializeComponent();
}
private void CloseButton_Click(object sender, EventArgs e)
{
Close();
}
private void OnTemplate(DPFP.Template template)
{
this.Invoke(new Function(delegate()
{
Template = template;
VerifyButton.Enabled = SaveButton.Enabled = (Template != null);
if (Template != null)
MessageBox.Show("The fingerprint template is ready for verification and saving", "Fingerprint Enrollment");
else
MessageBox.Show("The fingerprint template is not valid. Repeat fingerprint enrollment.", "Fingerprint Enrollment");
}));
}
private DPFP.Template Template;
private void EnrollButton_Click(object sender, EventArgs e)
{
EnrollmentForm Enroller = new EnrollmentForm();
Enroller.OnTemplate += this.OnTemplate;
Enroller.ShowDialog();
}
private void SaveButton_Click(object sender, EventArgs e)
{
obj.Last_name = txtLastname.Text;
obj.First_name = txtFirstName.Text;
obj.Middle_name = txtMiddleName.Text;
obj.Position_name = cmbPosition.Text;
obj.Company_name = cmbCompany.Text;
obj.Password = txtTempPassword.Text;
obj.Department_name = cmbDepartment.Text;
if (obj.Last_name == string.Empty) //Validation for empty texts
{
MessageBox.Show("Last name can't be empty!");
} else if (obj.First_name == string.Empty)
{
MessageBox.Show("First name can't be empty!");
}
else if (obj.Middle_name == string.Empty)
{
MessageBox.Show("Middle name can't be empty!");
}
else if (obj.Position_name == string.Empty)
{
MessageBox.Show("Position name can't be empty!");
}
else if (obj.Department_name == string.Empty)
{
MessageBox.Show("Deparment can't be empty!");
}
else if (obj.Company_name == string.Empty)
{
MessageBox.Show("Company name can't be empty!");
}
else if (obj.Password == string.Empty)
{
MessageBox.Show("Password can't be empty!");
}
else if (txtConfirmTempPassword.Text == string.Empty)
{
MessageBox.Show("Please verify your input password!");
}
else
{
if (txtTempPassword.Text != txtConfirmTempPassword.Text)
{
MessageBox.Show("Password does not match", "Password Mismatch",
MessageBoxButtons.OK);
}
else
{
MemoryStream fingerprintData = new MemoryStream();
Template.Serialize(fingerprintData);
fingerprintData.Position = 0;
BinaryReader br = new BinaryReader(fingerprintData);
Byte[] bytes = br.ReadBytes((Int32)fingerprintData.Length);
audit.Emp_id = emp_id;
obj.Biometric_code = bytes;
obj.AddAccountSetTempPassword();
}
}
}
private void VerifyButton_Click(object sender, EventArgs e)
{
VerificationForm Verifier = new VerificationForm();
Verifier.Verify(Template);
}
}
}
I'm setting it to frm.setEmpID so that I could get it from another form.
Thanks for the help man.
Perhaps in your SaveButton_Click event in the CreateAccount form you need to set also the Emp_Id variable of the obj instance defined inside that form (as you have done in the instance of the HRModuleBL defined in the first form).
private void SaveButton_Click(object sender, EventArgs e)
{
.....
audit.Emp_id = emp_id;
obj.Emp_id = emp_id;
obj.Biometric_code = bytes;
obj.AddAccountSetTempPassword();
.....
}

Categories