Пример #1
0
        protected void Button_Change_Details_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> targetVals   = new Dictionary <string, string>();
            Dictionary <String, String> whereCls     = new Dictionary <string, string>();
            Dictionary <String, String> whereClsProd = new Dictionary <string, string>();

            int[]     prodServ = ListBoxProdServc.GetSelectedIndices();
            ArrayList catList  = new ArrayList();

            for (int i = 0; i < prodServ.Length; i++)
            {
                catList.Add(ListBoxProdServc.Items[prodServ[i]].Value);
            }


            whereCls.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            whereClsProd.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_RELATED_PRODUCTS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());


            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_DESC, DropDownList_Business_Desc.SelectedValue);
            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_EMAIL_ID, TextBox_Email.Text);
            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_MOBILE_NO, TextBox_Contact.Text);
            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_OWNER_NAME, TextBox_Owner_Name.Text);
            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_SHOP_NAME, TextBox_Name.Text);
            targetVals.Add(BackEndObjects.MainBusinessEntity.MAIN_BUSINESS_COL_WEBSITE, TextBox_Site.Text);

            try
            {
                BackEndObjects.MainBusinessEntity.updateMainBusinessEntityWOimg_prd_user_subDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE);
                BackEndObjects.MainBusinessEntity.updateProductDetailsforEntityDB(null, whereClsProd, DBConn.Connections.OPERATION_DELETE);
                BackEndObjects.MainBusinessEntity.insertProductDetailsforEntityDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), catList);

                Label_Det_Change_Stat.Visible   = true;
                Label_Det_Change_Stat.Text      = "Details Changed Successfully";
                Label_Det_Change_Stat.ForeColor = System.Drawing.Color.Green;
            }
            catch (Exception ex)
            {
                Label_Det_Change_Stat.Visible   = true;
                Label_Det_Change_Stat.Text      = "Details Change Failed";
                Label_Det_Change_Stat.ForeColor = System.Drawing.Color.Red;
            }
        }
        protected void Buttin_Update_Click(object sender, EventArgs e)
        {
            int[]  prodServ = ListBoxProdServc.GetSelectedIndices();
            String prodList = "";

            for (int i = 0; i < prodServ.Length; i++)
            {
                if (i < (prodServ.Length - 1))
                {
                    prodList += ListBoxProdServc.Items[prodServ[i]].Value + ",";
                }
                else
                {
                    prodList += ListBoxProdServc.Items[prodServ[i]].Value;
                }
            }

            Dictionary <String, String> whereCls   = new Dictionary <string, string>();
            Dictionary <String, String> targetVals = new Dictionary <string, string>();

            whereCls.Add(BackEndObjects.Contacts.CONTACT_TABLE_COL_CONTACT_ENTITY_ID,
                         Session[SessionFactory.ALL_CONTACT_SELECTED_CONTACT_ID].ToString());
            whereCls.Add(BackEndObjects.Contacts.CONTACT_TABLE_COL_ENTITY_ID,
                         Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            targetVals.Add(BackEndObjects.Contacts.CONTACT_TABLE_COL_PROD_LIST, prodList);
            try
            {
                BackEndObjects.Contacts.updateContactDetailsDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE);
                Label_Status.Visible   = true;
                Label_Status.Text      = "Update Successful";
                Label_Status.ForeColor = System.Drawing.Color.Green;
                String contactEntId = Session[SessionFactory.ALL_CONTACT_SELECTED_CONTACT_ID].ToString();
                fillProdSrvDetails(contactEntId);
            }
            catch (Exception ex)
            {
                Label_Status.Visible   = true;
                Label_Status.Text      = "Update Failed";
                Label_Status.ForeColor = System.Drawing.Color.Red;
            }
        }
Пример #3
0
        protected void Buttin_Submit_Click(object sender, EventArgs e)
        {
            BackEndObjects.Contacts contactObj = (Contacts)Session[SessionFactory.CREATE_CONTACT_CONTACT_OBJ];
            if (contactObj == null && TextBox_Contact_Name.Text.Equals(""))
            {
                Label_Status.Text      = "Please select contact from the site or enter the details";
                Label_Status.ForeColor = System.Drawing.Color.Red;
                Label_Status.Visible   = true;
                Buttin_Submit.Focus();
            }
            else
            {
                if (contactObj == null)
                {
                    contactObj = new BackEndObjects.Contacts();
                    BackEndObjects.Id IdGen = new Id();

                    int[]  prodServ = ListBoxProdServc.GetSelectedIndices();
                    String prodList = "";

                    for (int i = 0; i < prodServ.Length; i++)
                    {
                        if (i < (prodServ.Length - 1))
                        {
                            prodList += ListBoxProdServc.Items[prodServ[i]].Value + ",";
                        }
                        else
                        {
                            prodList += ListBoxProdServc.Items[prodServ[i]].Value;
                        }
                    }

                    contactObj.setContactEntityId(IdGen.getNewId(BackEndObjects.Id.ID_TYPE_CMP_USR_STRING));
                    contactObj.setContactName(TextBox_Contact_Name.Text);
                    contactObj.setContactShortName(TextBox_Contact_ShortName.Text);
                    contactObj.setEmailID(TextBox_EmailId.Text);
                    contactObj.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                    contactObj.setFromSite("N");
                    String localId = (!DropDownList_Locality.SelectedValue.Equals("_") && !DropDownList_Locality.SelectedValue.Equals("") ?
                                      DropDownList_Locality.SelectedValue : (!DropDownList_City.SelectedValue.Equals("_") && !DropDownList_City.SelectedValue.Equals("") ?
                                                                             DropDownList_City.SelectedValue : (!DropDownList_State.SelectedValue.Equals("_") && !DropDownList_State.SelectedValue.Equals("") ?
                                                                                                                DropDownList_State.SelectedValue : (!DropDownList_Country.SelectedValue.Equals("_") && !DropDownList_Country.SelectedValue.Equals("") ?
                                                                                                                                                    DropDownList_Country.SelectedValue : ""))));

                    contactObj.setLocalityId(localId);
                    contactObj.setMobNo(TextBox_Contact_No.Text);
                    contactObj.setStreetName(TextBox_Street_Name.Text);
                    contactObj.setProdList(prodList);
                }
                else
                {
                    contactObj = (BackEndObjects.Contacts)Session[SessionFactory.CREATE_CONTACT_CONTACT_OBJ];
                    contactObj.setContactShortName(TextBox_Contact_ShortName.Text);
                    Session.Remove(SessionFactory.CREATE_CONTACT_ADDRESS_LINE1);
                    Session.Remove(SessionFactory.CREATE_CONTACT_CONTACT_OBJ);
                    Session.Remove(SessionFactory.CREATE_CONTACT_LOCALITY_ID);
                }

                try
                {
                    bool found = false;

                    Dictionary <String, Dictionary <String, String> > existingContactDict = (Dictionary <String, Dictionary <String, String> >)Session[SessionFactory.ALL_CONTACT_EXISTING_CONTACT_LIST];
                    if (existingContactDict != null && existingContactDict.Count > 0)
                    {
                        Dictionary <String, String> existingContactNames      = existingContactDict["names"];
                        Dictionary <String, String> existingContactShortNames = existingContactDict["shortnames"];
                        Dictionary <String, String> existingContactEmailIds   = existingContactDict["emailids"];
                        Dictionary <String, String> existingContactPhNos      = existingContactDict["phonenos"];

                        if (existingContactShortNames != null && existingContactShortNames.ContainsKey(contactObj.getContactShortName()))
                        {
                            found = true;
                        }
                        else if (existingContactNames != null && existingContactNames.ContainsKey(contactObj.getContactName()))
                        {
                            found = true;
                        }
                        else if (existingContactEmailIds != null && existingContactEmailIds.ContainsKey(contactObj.getEmailId()))
                        {
                            found = true;
                        }
                        else if (existingContactPhNos != null && existingContactPhNos.ContainsKey(contactObj.getMobNo()))
                        {
                            found = true;
                        }
                    }

                    if (found)
                    {
                        Label_Status.Text      = "Contact Exists with similar details. Please recheck";
                        Label_Status.ForeColor = System.Drawing.Color.Red;
                        Label_Status.Visible   = true;
                        Buttin_Submit.Focus();
                    }
                    else
                    {
                        BackEndObjects.Contacts.insertContactDetailsDB(contactObj);
                        Label_Status.Text      = "Contact created successfully";
                        Label_Status.ForeColor = System.Drawing.Color.Green;
                        Label_Status.Visible   = true;
                        Buttin_Submit.Focus();
                        Dictionary <String, String> allExistingContacts = (Dictionary <String, String>)Session[SessionFactory.EXISTING_CONTACT_DICTIONARY];
                        if (!allExistingContacts.ContainsKey(contactObj.getContactName()))
                        {
                            allExistingContacts.Add(contactObj.getContactName(), contactObj.getContactEntityId());
                        }
                        Session[SessionFactory.EXISTING_CONTACT_DICTIONARY] = allExistingContacts;

                        if (existingContactDict != null && existingContactDict.Count > 0)
                        {
                            Dictionary <String, String> existingContactNames      = existingContactDict["names"];
                            Dictionary <String, String> existingContactShortNames = existingContactDict["shortnames"];
                            Dictionary <String, String> existingContactEmailIds   = existingContactDict["emailids"];
                            Dictionary <String, String> existingContactPhNos      = existingContactDict["phonenos"];

                            if (existingContactShortNames != null && !existingContactShortNames.ContainsKey(contactObj.getContactShortName()) && !contactObj.getContactShortName().Equals(""))
                            {
                                existingContactShortNames.Add(contactObj.getContactShortName(), "");
                            }
                            if (existingContactNames != null && !existingContactNames.ContainsKey(contactObj.getContactName()) && !contactObj.getContactName().Equals(""))
                            {
                                existingContactNames.Add(contactObj.getContactName(), "");
                            }
                            if (existingContactEmailIds != null && !existingContactEmailIds.ContainsKey(contactObj.getEmailId()) && !contactObj.getEmailId().Equals(""))
                            {
                                existingContactEmailIds.Add(contactObj.getEmailId(), "");
                            }
                            if (existingContactPhNos != null && !existingContactPhNos.ContainsKey(contactObj.getMobNo()) && !contactObj.getMobNo().Equals(""))
                            {
                                existingContactPhNos.Add(contactObj.getMobNo(), "");
                            }

                            existingContactDict.Clear();
                            existingContactDict.Add("names", existingContactNames);
                            existingContactDict.Add("shortnames", existingContactShortNames);
                            existingContactDict.Add("emailids", existingContactEmailIds);
                            existingContactDict.Add("phonenos", existingContactPhNos);
                            Session[SessionFactory.ALL_CONTACT_EXISTING_CONTACT_LIST] = existingContactDict;
                        }


                        if (Request.QueryString.GetValues("parentContext") != null)
                        {
                            String parentContext = Request.QueryString.GetValues("parentContext")[0];
                            if (parentContext.Equals("lead") || parentContext.Equals("potn") || parentContext.Equals("rfq") || parentContext.Equals("broadcast") || parentContext.Equals("defect") || parentContext.Equals("sr"))
                            {
                                ScriptManager.RegisterStartupScript(this, typeof(string), "DispContactLead", "RefreshParent();", true);
                            }
                        }
                        else
                        {
                            DataTable dt = (DataTable)Session[SessionFactory.ALL_CONTACT_DATA_GRID];
                            dt.Rows.Add();

                            int i = dt.Rows.Count - 1;

                            dt.Rows[i]["ContactEntId"] = contactObj.getContactEntityId();
                            dt.Rows[i]["ContactName"]  = contactObj.getContactName();
                            dt.Rows[i]["ShortName"]    = contactObj.getContactShortName();
                            dt.Rows[i]["PhNo"]         = contactObj.getMobNo();
                            dt.Rows[i]["EmailId"]      = contactObj.getEmailId();
                            dt.Rows[i]["FromSite"]     = contactObj.getFromSite();

                            dt.DefaultView.Sort = "ContactName" + " " + "ASC";
                            Session[SessionFactory.ALL_CONTACT_DATA_GRID] = dt.DefaultView.ToTable();

                            ScriptManager.RegisterStartupScript(this, typeof(string), "updateContactGrid", "RefreshParentPostCreation();", true);
                        }
                    }

                    /*ListItem lt = new ListItem();
                     * lt.Text = (contactObj.getContactShortName() != null && !contactObj.getContactShortName().Equals("") ? contactObj.getContactShortName() :
                     *  contactObj.getContactName());
                     * lt.Value = contactObj.getContactEntityId();
                     *
                     * DropDownList prevDropList = PreviousPage.FindControl("DropDownList_Contacts") as DropDownList;
                     * ((DropDownList)Page.PreviousPage.FindControl("DropDownList_Contacts")).Items.Add(lt);*/
                }
                catch (Exception ex)
                {
                    Label_Status.Text      = "Contact creation failed";
                    Label_Status.ForeColor = System.Drawing.Color.Red;
                    Label_Status.Visible   = true;
                    Buttin_Submit.Focus();
                }
            }
        }
Пример #4
0
        /// <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;
        }