public ActionResult CreateCustomer(CustomerDetails_3 c, FormCollection f)
        {
            //c.State_3 = f["State_Name_3"];
            // c.City_3 = f["City_Name_3"];
            int state_id = Convert.ToInt32(c.State_3);
            int city_id  = Convert.ToInt32(c.City_3);
            var temp     = db.Select_State_3.Where(a => a.State_ID_3 == state_id).ToList();

            if (temp != null)
            {
                foreach (var l in temp)
                {
                    c.State_3 = l.State_Name_3;
                }
            }
            var temp1 = db.Select_City_3.Where(x => x.City_ID_3 == city_id).ToList();

            if (temp1 != null)
            {
                foreach (var l in temp1)
                {
                    c.City_3 = l.City_Name_3;
                }
            }
            if (ModelState.IsValid)
            {
                ObjectParameter op = new ObjectParameter("CustomerID_3", 0);
                db.create_customer_3(c.CustomerSSID_3, c.CustomerName_3, c.Age_3, c.CustomerAddress_3, c.State_3, c.City_3, op);
                db.SaveChanges();
                ModelState.Clear();
                if (Convert.ToInt32(op.Value) == 0)
                {
                    Response.Write("<script>alert('Registration Unsuccessful!!! Try Re-Registering')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Registration Successful!!! The Customer ID is : " + op.Value + "')</script>");
                    State_List();
                    return(View());
                }
            }
            State_List();
            return(View());
        }
Beispiel #2
0
        public ActionResult CreateAccount(AccountDetails_3 acc)
        {
            try {
                if (ModelState.IsValid)
                {
                    ObjectParameter d = new ObjectParameter("id", 0);
                    db.accountcheckteam3(acc.CustomerID_3, d);
                    if (Convert.ToInt64(d.Value) == 0)
                    {
                        Response.Write("<script>alert('invalid customer_ID')</script>");
                        return(View());
                    }
                    else
                    {
                        ObjectParameter s = new ObjectParameter("accountid", 0);
                        db.createaccountteam3(acc.CustomerID_3, acc.AccountType_3, acc.Balance_3, s);

                        long accid = Convert.ToInt64(s.Value);
                        // string bal = Convert.ToString(acc.AccountType_3);

                        if (accid == 0)
                        {
                            Response.Write("<script>alert(' user already have an account" + acc.AccountType_3 + "')</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('Successfully created a account with account_ID=" + accid + "')</script>");
                        }
                        db.SaveChanges();
                        ModelState.Clear();
                    }
                }
            }
            catch (Exception e)
            {
                Response.Write("<script>alert('Please enter Custromer_ID')</script>");
            }
            return(View("CreateAccount"));
        }