protected void populateLogo() { ArrayList imgListObjs = BackEndObjects.Image.getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; ((System.Web.UI.WebControls.Image)Master.FindControl("Image_Logo")).ImageUrl = imageToURL(imgObj.getImgPath()); ((System.Web.UI.WebControls.Image)Master.FindControl("Image_Logo")).Visible = true; } }
protected void Button_Insert_Image_Click(object sender, EventArgs e) { BackEndObjects.Image imgObj = new BackEndObjects.Image(); imgObj.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); imgObj.setFileStream(FileUpload1); imgObj.setImgId(new BackEndObjects.Id().getNewId(BackEndObjects.Id.ID_TYPE_IMAGE_ID_STRING)); imgObj.setImgPath(); imgObj.setImgType(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO); imgObj.setReferenceId(""); ArrayList imgList = new ArrayList(); imgList.Add(imgObj); try { ArrayList imgListObjs = BackEndObjects.Image.getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); for (int i = 0; i < imgListObjs.Count; i++) { BackEndObjects.Image oldImgObj = (BackEndObjects.Image)imgListObjs[i]; BackEndObjects.Image.updateImageforEntityDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), oldImgObj.getImgId(), DBConn.Connections.OPERATION_DELETE); String[] imageNameParts = null; if (oldImgObj.getImgPath() != null && !oldImgObj.getImgPath().Equals("")) { imageNameParts = oldImgObj.getImgPath().Split(new String[] { "\\" }, StringSplitOptions.RemoveEmptyEntries); } String finalImageUrl = "~/Images/SessionImages/" + Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString() + "/" + imageNameParts[imageNameParts.Length - 1]; //Remove the existing logo copy from website storage if (File.Exists(Server.MapPath(finalImageUrl))) { File.Delete(Server.MapPath(finalImageUrl)); } } BackEndObjects.Image.insertImageforEntityDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), imgList); Label_Upload_Logo.Visible = true; Label_Upload_Logo.Text = "Image Uploaded Successfully"; Label_Upload_Logo.ForeColor = System.Drawing.Color.Green; populateLogo(); } catch (Exception ex) { Label_Upload_Logo.Visible = true; Label_Upload_Logo.Text = "Image Upload Failed"; Label_Upload_Logo.ForeColor = System.Drawing.Color.Red; } }
protected void populateLogo(String otherEntId, String context) { if (context.Equals("client") || context.Equals("clientInvoiceGrid")) { ArrayList imgListObjs = BackEndObjects.Image. getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, otherEntId); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; Image_Logo_Vendor.ImageUrl = imageToURL(imgObj.getImgPath()); Image_Logo_Vendor.Visible = true; } imgListObjs.Clear(); imgListObjs = BackEndObjects.Image. getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; Image_Logo_Client.ImageUrl = imageToURL(imgObj.getImgPath()); Image_Logo_Client.Visible = true; } } else { ArrayList imgListObjs = BackEndObjects.Image. getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, otherEntId); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; Image_Logo_Client.ImageUrl = imageToURL(imgObj.getImgPath()); Image_Logo_Client.Visible = true; } imgListObjs.Clear(); imgListObjs = BackEndObjects.Image. getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; Image_Logo_Vendor.ImageUrl = imageToURL(imgObj.getImgPath()); Image_Logo_Vendor.Visible = true; } } }
protected void populateLogo() { String context = Request.QueryString.GetValues("context")[0]; ArrayList imgListObjs = BackEndObjects.Image.getImagebyTypeandEntId(BackEndObjects.Image.PICTURE_IMG_TYPE_LOGO, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); if (imgListObjs.Count > 0) { //Only consider the first image object for logo BackEndObjects.Image imgObj = (BackEndObjects.Image)imgListObjs[0]; if (context.Equals("client")) { Image_Logo.ImageUrl = imgObj.getImgPath(); Image_Logo.Visible = true; } else { Image_Logo1.ImageUrl = imgObj.getImgPath(); Image_Logo1.Visible = true; } } }
/// <summary> /// Complete registration for the business entity /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { String shortRegstr = (Session[SessionFactory.SHORT_REGISTR_COMPLETE] != null ? Session[SessionFactory.SHORT_REGISTR_COMPLETE].ToString() : ""); bool shortRegstrCompl = ((shortRegstr != null && shortRegstr.Equals("true"))? true : false); ActionLibrary.RegistrationActions regstr = new ActionLibrary.RegistrationActions(); BackEndObjects.MainBusinessEntity mBE = new MainBusinessEntity(); mBE.setEntityName(TextBox5.Text); mBE.setEmailId(TextBox4.Text); mBE.setWebSite(TextBox7.Text); mBE.setIndChain(DropDownList1.SelectedValue.Trim()); mBE.setOwnerName(TextBox6.Text); mBE.setDesc(DropDownListDescr.SelectedValue); mBE.setPhNo(TextBox10.Text); String mBEId = ""; BackEndObjects.Id IdGen = new BackEndObjects.Id(); if (!shortRegstrCompl) { mBEId = IdGen.getNewId(Id.ID_TYPE_CMP_USR_STRING); } else { mBEId = (Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING] != null ? Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString() : ""); } mBE.setEntityId(mBEId); int[] prodServ = ListBoxProdServc.GetSelectedIndices(); Dictionary <String, ProductCategory> prdDict = new Dictionary <string, BackEndObjects.ProductCategory>(); Dictionary <String, ProductCategory> prodCatMBE = MainBusinessEntity.getProductDetailsforMainEntitybyIdDB(mBE.getEntityId()); for (int i = 0; i < prodServ.Length; i++) { ProductCategory ePd = new ProductCategory(); //Add products/service which are not already added for the Main business entity - this is to avoid error situation //when the user by mistake clicks twice in the submit button in the registration page if (!prodCatMBE.ContainsKey(ListBoxProdServc.Items[prodServ[i]].Value)) { ePd.setCategoryId(ListBoxProdServc.Items[prodServ[i]].Value); ePd.setProductCategoryName(ListBoxProdServc.Items[prodServ[i]].Text); prdDict.Add(ePd.getCategoryId(), ePd); } } mBE.setMainProductServices(prdDict); userDetails uD = new userDetails(); Boolean userIdAlreadyExistis = false; if (!shortRegstrCompl) { userDetails udTest = BackEndObjects.userDetails.getUserDetailsbyIdDB(TextBox1.Text); if (udTest.getUserId() == null || udTest.getUserId().Equals("")) //New user id { uD.setMainEntityId(mBEId); Random ranGen = new Random(); int saltInt = ranGen.Next(1, 16); byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes((TextBox2.Text.Equals("") ? TextBox2.Attributes["password"] : TextBox2.Text) + saltInt); HashAlgorithm hashConverter = new SHA256Managed(); byte[] hashedByteStream = hashConverter.ComputeHash(plainTextBytes); String encryptedAndConvertedPassword = Convert.ToBase64String(hashedByteStream); uD.setPassword(encryptedAndConvertedPassword); uD.setUserId(TextBox1.Text); uD.setMainEntityId(mBE.getEntityId()); uD.setSalt(saltInt.ToString()); uD.setPrivilege(BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_OWNER_ACCESS); } else { Label_UserId_Exists.Visible = true; Label_UserId_Exists.Text = "User Id not available.. please enter a different one"; userIdAlreadyExistis = true; } } AddressDetails aD = new AddressDetails(); AddressDetails aDTest = AddressDetails.getAddressforMainBusinessEntitybyIdDB(mBE.getEntityId()); //If Address detais for this main business entity is not already set up - this is to handle error situation. //when the user by mistake clicks twice in the submit button in the registration page //Because as of now, the backend only accepts one address detail for the main business entity if (aDTest.getLocalityId() == null || aDTest.getLocalityId().Equals("")) { aD.setAddrLine1(TextBox8.Text); aD.setLocalityId(DropDownList5.SelectedValue); aD.setBaseCurrencyId(DropDownListBaseCurr.SelectedValue); aD.setMainBusinessId(mBEId); aD.setSubEntityId(AddressDetails.DUMMY_CHAIN_ID); } //FileUpload fU = FileUpload1; //Removing the option of image upload in registration page BackEndObjects.Image imgObj = new BackEndObjects.Image(); /*if (fU != null && fU.HasFile) * { * imgObj.setImgId(IdGen.getNewId(Id.ID_TYPE_IMAGE_ID_STRING)); * imgObj.setEntityId(mBE.getEntityId()); * imgObj.setFileStream(fU); * imgObj.setImgPath(); * }*/ Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING] = mBEId; ArrayList regstObjs = new ArrayList(); if (mBE.getEntityId() != null && !mBE.getEntityId().Equals("")) { regstObjs.Add(mBE); } if (uD.getUserId() != null && !uD.getUserId().Equals("")) { regstObjs.Add(uD); } if (aD.getLocalityId() != null && !aD.getLocalityId().Equals("")) { regstObjs.Add(aD); } if (imgObj.getImgId() != null && !imgObj.getImgId().Equals("")) { regstObjs.Add(imgObj); } try { if (!userIdAlreadyExistis) { regstr.completeRegr(regstObjs); Label_Status.Visible = true; Label_Status.ForeColor = System.Drawing.Color.Green; Label_Status.Text = "Data inserted successfully"; Button_Register_Business.Enabled = false; Button_Register_Short.Enabled = false; } } catch (Exception ex) { Label_Status.Visible = true; Label_Status.ForeColor = System.Drawing.Color.Red; Label_Status.Text = "Error entering details"; } HyperLink1.Visible = true; }