Пример #1
0
        protected void fillGrid()
        {
            ArrayList mBEList = BackEndObjects.MainBusinessEntity.getMainBusinessEntityListbyNameWithAddrDetailsDB(TextBox_Search_Contact.Text,
                                                                                                                   Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

            if (mBEList == null || mBEList.Count == 0)
            {
                Label_Status_Search.Visible   = true;
                Label_Status_Search.ForeColor = System.Drawing.Color.Red;
                Label_Status_Search.Text      = "No company found for the given id";
                GridView1.Visible             = false;
            }

            else
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Name");
                dt.Columns.Add("Country");
                dt.Columns.Add("State");
                dt.Columns.Add("City");
                dt.Columns.Add("Locality");
                dt.Columns.Add("Street Name");
                dt.Columns.Add("Mob");
                dt.Columns.Add("Email");
                dt.Columns.Add("Contact Exists?");
                dt.Columns.Add("localId");
                dt.Columns.Add("ContactEntId");

                for (int i = 0; i < mBEList.Count; i++)
                {
                    //MainBusinessEntity mBEObj = BackEndObjects.MainBusinessEntity.getMainBusinessEntitybyIdwithLessDetailsDB(TextBox_Search_Contact.Text);
                    MainBusinessEntity mBEObj  = (MainBusinessEntity)mBEList[i];
                    AddressDetails     mBEAddr = mBEObj.getAddressDetails();

                    Contacts contactObj = Contacts.
                                          getContactDetailsforContactEntityDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), mBEObj.getEntityId());

                    Label_Status_Search.Visible = false;

                    BackEndObjects.Localities localObj   = null;
                    BackEndObjects.City       cityObj    = null;
                    BackEndObjects.State      stateObj   = null;
                    BackEndObjects.Country    countryObj = null;

                    if (mBEAddr.getLocalityId() != null && !mBEAddr.getLocalityId().Equals(""))
                    {
                        localObj   = Localities.getLocalitybyIdDB(mBEAddr.getLocalityId());
                        cityObj    = BackEndObjects.Localities.getCityDetailsforLocalitywoOtherAsscLocalitiesDB(mBEAddr.getLocalityId());
                        stateObj   = BackEndObjects.City.getStateDetailsforCitywoOtherAsscCitiesDB(cityObj.getCityId());
                        countryObj = BackEndObjects.State.getCountryDetailsforStatewoOtherAsscStatesDB(stateObj.getStateId());
                        //Session[SessionFactory.CREATE_CONTACT_LOCALITY_ID] = localObj.getLocalityId();
                        //Session[SessionFactory.CREATE_CONTACT_ADDRESS_LINE1] = mBEAddr.getAddrLine1();
                    }


                    dt.Rows.Add();

                    dt.Rows[i]["Name"] = mBEObj.getEntityName();
                    if (mBEAddr.getLocalityId() != null && !mBEAddr.getLocalityId().Equals(""))
                    {
                        dt.Rows[i]["Country"]      = countryObj.getCountryName();
                        dt.Rows[i]["State"]        = stateObj.getStateName();
                        dt.Rows[i]["City"]         = cityObj.getCityName();
                        dt.Rows[i]["Locality"]     = localObj.getLocalityName();
                        dt.Rows[i]["Street Name"]  = mBEAddr.getAddrLine1();
                        dt.Rows[i]["localId"]      = mBEAddr.getLocalityId();
                        dt.Rows[i]["ContactEntId"] = mBEAddr.getMainBusinessId();
                    }
                    else
                    {
                        dt.Rows[i]["Country"]      = "N/A";
                        dt.Rows[i]["State"]        = "N/A";
                        dt.Rows[i]["City"]         = "N/A";
                        dt.Rows[i]["Locality"]     = "N/A";
                        dt.Rows[i]["Street Name"]  = "N/A";
                        dt.Rows[i]["localId"]      = "";
                        dt.Rows[i]["ContactEntId"] = mBEObj.getEntityId();
                    }
                    dt.Rows[i]["Mob"]             = mBEObj.getPhNo();
                    dt.Rows[i]["Email"]           = mBEObj.getEmailId();
                    dt.Rows[i]["Contact Exists?"] = ((contactObj.getContactEntityId() != null && !contactObj.getContactEntityId().Equals("")) ? "Y" : "N");
                }
                GridView1.DataSource = dt;
                GridView1.DataBind();
                GridView1.Visible             = true;
                GridView1.Columns[10].Visible = false;
                GridView1.Columns[11].Visible = false;


                Session[SessionFactory.CREATE_CONTACT_DATA_GRID] = dt;
            }
        }
Пример #2
0
        protected void Button_Change_Addr_Click(object sender, EventArgs e)
        {
            AddressDetails addrObj = BackEndObjects.AddressDetails.
                                     getAddressforMainBusinessEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

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

            Boolean update = false;

            //If address is already present then its a update request
            if (addrObj != null && addrObj.getMainBusinessId() != null)
            {
                update = true;
                whereCls.Add(BackEndObjects.AddressDetails.ADDR_DETAILS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                whereCls.Add(BackEndObjects.AddressDetails.ADDR_DETAILS_COL_CHAIN_ID, "");
                targetVals.Add(BackEndObjects.AddressDetails.ADDR_DETAILS_COL_ADDR_LINE1, TextBox_Street_Name.Text);
                targetVals.Add(BackEndObjects.AddressDetails.ADDR_DETAILS_COL_LOCALITY_ID, DropDownList_Locality.SelectedValue);
                targetVals.Add(BackEndObjects.AddressDetails.ADDR_DETAILS_COL_BASE_CURR, DropDownList_Base_Curr.SelectedValue);
            }
            else
            {
                BackEndObjects.AddressDetails addressObj = new AddressDetails();

                addressObj.setAddrLine1(TextBox_Street_Name.Text);
                addressObj.setLocalityId(DropDownList_Locality.SelectedValue);
                addressObj.setBaseCurrencyId(DropDownList_Base_Curr.SelectedValue);
                addressObj.setMainBusinessId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                addressObj.setSubEntityId(BackEndObjects.AddressDetails.DUMMY_CHAIN_ID);

                addrObjList.Add(addressObj);
            }
            try
            {
                if (update)
                {
                    BackEndObjects.AddressDetails.updateAddressEntityDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE);
                }
                else
                {
                    BackEndObjects.AddressDetails.insertAddressEntityDB(addrObjList);
                }

                Label_Addr_Change_Stat.Visible   = true;
                Label_Addr_Change_Stat.Text      = "Details updated successfully";
                Label_Addr_Change_Stat.ForeColor = System.Drawing.Color.Green;

                Label_Addr1.Text = TextBox_Street_Name.Text;
                String localId = !DropDownList_Locality.SelectedValue.Equals("") ? DropDownList_Locality.SelectedValue :
                                 !DropDownList_City.SelectedValue.Equals("") ? DropDownList_City.SelectedValue :
                                 !DropDownList_State.SelectedValue.Equals("") ? DropDownList_State.SelectedValue : DropDownList_Country.SelectedValue;
                loadLocalityDetails(localId);
            }
            catch (Exception ex)
            {
                Label_Addr_Change_Stat.Visible   = true;
                Label_Addr_Change_Stat.Text      = "Update Failed";
                Label_Addr_Change_Stat.ForeColor = System.Drawing.Color.Red;
            }
        }