protected void btnsubmit_Click(object sender, EventArgs e) { permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); permission.permissionmaster_SRNO = -1; permission.permissionmaster_USERID =-1; foreach (ListItem aListItem in rdcmplist.Items) { if (aListItem.Selected) { permission.permissionmaster_SRNO=-1; permission.permissionmaster_USERID=-1; permission.permissionmaster_CMPID = General.Parse<int>(aListItem.Value.ToString().Trim()); permission.permissionmaster_PREFFERED = 1; permission.permissionmaster_BRANCHID = -1; permission.permissionmaster_STATUS =-1; string condition = "BRANCHID = NULL AND PREFFERED =1 AND STATUS=0 AND USERID ="+Session["userid"].ToString()+" AND CMPID=" + aListItem.Value.ToString().Trim(); if (permission.Insert(false, "permissionmaster",condition)) { } } } }
protected void btnSave_Click(object sender, EventArgs e) { int cmpcount = 0; int branchcount = 0; foreach (ListItem aListItem in chkcmplist.Items) { if (aListItem.Selected) { cmpcount = 1; foreach (ListItem aListItem1 in chkbranchlist.Items) { if (aListItem1.Selected) { branchcount = 1; break; } } break; } } if (cmpcount > 0 && branchcount > 0) { usertable user = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); user.usertable_SRNO = -1; user.usertable_NAME = txtname.Text; user.usertable_DESIGNATION = ddldesignation.SelectedItem.Text.Trim().ToString(); user.usertable_DEPARTMENT = ddldepartment.SelectedItem.Text.Trim().ToString(); if (rdfemale.Checked) { user.usertable_GENDER = "FEMALE"; } else { user.usertable_GENDER = "MALE"; } user.usertable_EMAIL = txtemail.Text; user.usertable_PHONE = txtphone.Text; user.usertable_USERID = txtuserid.Text; user.usertable_PASSWORD = GenerateRandomCode(); user.usertable_STATUS = 0; if (user.Insert(true, "usertable")) { int i = 0; foreach (ListItem aListItem in chkcmplist.Items) { if (aListItem.Selected) { permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); permission.permissionmaster_SRNO = -1; permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim()); permission.permissionmaster_CMPID = General.Parse<int>(aListItem.Value.ToString().Trim()); if (i == 0) { permission.permissionmaster_PREFFERED = 1; } else { permission.permissionmaster_PREFFERED = 0; } permission.permissionmaster_BRANCHID = -1; permission.permissionmaster_STATUS = 0; if (permission.Insert(true, "permissionmaster")) { } } } i = 0; foreach (ListItem aListItem in chkbranchlist.Items) { if (aListItem.Selected) { permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); permission.permissionmaster_SRNO = -1; permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim()); permission.permissionmaster_BRANCHID = General.Parse<int>(aListItem.Value.ToString().Trim()); if (i == 0) { permission.permissionmaster_PREFFERED = 1; } else { permission.permissionmaster_PREFFERED = 0; } permission.permissionmaster_CMPID = -1; permission.permissionmaster_STATUS = 0; if (permission.Insert(true, "permissionmaster")) { } } } } MessageBox("User Created Successfully"); FillUser(); } }