Example #1
0
        public ActionResult EmpHomeDistrict(EmpAddressDetail empAddressDetail)

        {
            connection();
            //string data=TempData["mydata"] as string;

            string emp_code = Session["empCode"].ToString();

            SqlCommand sqlcmd = new SqlCommand("Insert into emp_address (emp_code, h_State, h_district, h_Tehsil, h_Vidhan_Sabha, p_state, p_district, p_town, p_add, c_state, c_district, c_town, c_add, c_phone, c_mobile, c_email) values('"
                                               + emp_code + "','" + empAddressDetail.h_state + "','" + empAddressDetail.h_district + "','" + empAddressDetail.h_tehsil + "','" + empAddressDetail.h_vidhan_sabha + "'," + "'" + empAddressDetail.p_state + "','"
                                               + empAddressDetail.p_district + "','" + empAddressDetail.p_town + "','" + empAddressDetail.p_add + "','" + empAddressDetail.c_state + "','" + empAddressDetail.c_district + "','" + empAddressDetail.c_town +
                                               "','" + empAddressDetail.c_add + "','" + empAddressDetail.c_phone + "','" + empAddressDetail.c_mobile + "','" + empAddressDetail.c_email + "')", con);

            sqlcmd.CommandType = CommandType.Text;

            con.Open();
            sqlcmd.ExecuteNonQuery();
            con.Close();
            return(RedirectToAction("EmpFamilyDetail"));
        }
        public int postContactDetail(EmpAddressDetail empAddressDetail)
        {
            db.Configuration.ProxyCreationEnabled = false;

            Address address = new Address();

            address.AddressName = empAddressDetail.AddressName;
            address.Address1 = empAddressDetail.Address1;
            address.Address2 = empAddressDetail.Address2;
            address.City = empAddressDetail.City;
            address.State = empAddressDetail.State;
            address.Pincode = empAddressDetail.PinCode;
            address.AddressTypId = empAddressDetail.AddressType;

            db.Addresses.Add(address);

            if (db.SaveChanges() == 1)
            {
                EntityAddress entityAddress = new EntityAddress();
                entityAddress.AddressId = address.AddressId;
                entityAddress.EntityTypId = 1;
                entityAddress.EntityId = empAddressDetail.EmpId;
                db.EntityAddresses.Add(entityAddress);
            }

            return db.SaveChanges();
        }