public async Task <ActionResult> DeleteConfirmed(int id)
        {
            app_cus_contact app_cus_contact = await db.app_cus_contact.FindAsync(id);

            db.app_cus_contact.Remove(app_cus_contact);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <ActionResult> EditCustomer([Bind(Include = "id,citizenship,home_type_code,age_cat_type_code,cus_type_code,title,firstname,lastname,middlename,dob,gender,security_code,occupation_code,img_url,sign_img_url,marital_status,child_num,cus_since,cus_doc_code,credit_limit,kin_type_code,created_by,modified_by,deleted_by,created_date,modified_date,deleted_date,rel_off_code,bran_code")]
                                                      app_cus_main app_cus_main
                                                      , app_cus_other_info app_cus_other_info
                                                      , app_cus_contact app_cus_contact
                                                      , app_gender app_gender
                                                      , app_kin_details app_kin_details

                                                      )



        {
            ViewBag.alert = "";
            var errors = this.ViewData.ModelState.Values.SelectMany(modelState => modelState.Errors, (modelState, error) => error.ErrorMessage).ToArray();

            if (ModelState.IsValid)
            //  return View(app_cus_main);
            {
                app_cus_main.modified_by = _repository.GetLoginUser();
                // app_cus_main.modified_date = _repository.GetCurrentDateTime();
                //  app_cus_main.cus_code=
                app_cus_main.app_cus_contact    = app_cus_contact;
                app_cus_main.app_kin_details    = app_kin_details;
                app_cus_main.app_cus_other_info = app_cus_other_info;

                app_cus_main.cus_code = _repository.GetCustomerCode(app_cus_main.id);
                db.app_cus_main.Add(app_cus_main);
                app_cus_main.img_url = "/image/photo";
                app_cus_main.status  = "ini";
                // app_cus_main.status = "ini";
                app_cus_main.sign_img_url    = "/image/signature";
                db.Entry(app_cus_main).State = EntityState.Modified;
                await db.SaveChangesAsync();

                ViewBag.alert = "saved";
                return(RedirectToAction("Index"));
            }
            ViewBag.alert             = "error";
            ViewBag.citizenship       = new SelectList(db.app_countries, "id", "name");
            ViewBag.home_type_code    = new SelectList(db.app_home_type, "id", "type_name", app_cus_main.home_type_code);
            ViewBag.gender            = new SelectList(db.app_gender, "id", "sex", app_cus_main.gender);
            ViewBag.age_cat_type_code = new SelectList(db.app_age_cate, "id", "name_of_cat", app_cus_main.age_cat_type_code);
            ViewBag.bran_code         = new SelectList(db.app_branch, "id", "branch_name", app_cus_main.bran_code);
            ViewBag.contact_code      = new SelectList(db.app_cus_contact, "id", "tele_number", app_cus_main.contact_code);
            ViewBag.cus_doc_code      = new SelectList(db.app_cus_doc, "id", "cus_doc_name", app_cus_main.cus_doc_code);
            ViewBag.cus_other_code    = new SelectList(db.app_cus_other_info, "id", "cus_other_code", app_cus_main.cus_other_code);
            ViewBag.cus_type_code     = new SelectList(db.app_cus_type, "id", "type_name", app_cus_main.cus_type_code);
            ViewBag.kin_details_code  = new SelectList(db.app_kin_details, "id", "kin_details_code", app_cus_main.kin_details_code);
            ViewBag.occupation_code   = new SelectList(db.app_occupation, "id", "name", app_cus_main.occupation_code);
            ViewBag.rel_off_code      = new SelectList(db.app_rel_office, "id", "full_name", app_cus_main.rel_off_code);
            ViewBag.home_type_code    = new SelectList(db.app_home_type, "id", "type_name");

            return(View(app_cus_main));
        }
        public async Task <ActionResult> Edit([Bind(Include = "id,country_code,contact_code,tele_number,fax,email,address1,address2,city,state,zip,brief_location,gps_cordinates")] app_cus_contact app_cus_contact)
        {
            if (ModelState.IsValid)
            {
                db.Entry(app_cus_contact).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(app_cus_contact));
        }
        // GET: app_cus_contact/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            app_cus_contact app_cus_contact = await db.app_cus_contact.FindAsync(id);

            if (app_cus_contact == null)
            {
                return(HttpNotFound());
            }
            return(View(app_cus_contact));
        }
Пример #5
0
        public ActionResult DelCustomer([Bind(Include = "id,home_type_code,age_cat_type_code,cus_type_code,title,firstname,lastname,middlename,dob,gender,occupation_code,img_url,sign_img_url,marital_status,child_num,cus_since,cus_doc_code,credit_limit,kin_type_code,created_by,modified_by,deleted_by,created_date,modified_date,deleted_date,rel_off_code,bran_code")]
                                        app_cus_main app_cus_main
                                        , app_cus_other_info app_cus_other_info
                                        , app_cus_contact app_cus_contact
                                        , app_kin_details app_kin_details
                                        )

        {
            if (ModelState.IsValid)
            //  return View(app_cus_main);
            {
                app_cus_main.modified_by        = _repository.GetLoginUser();
                app_cus_main.modified_date      = _repository.GetCurrentDateTime();
                app_cus_main.status             = "del";
                app_cus_main.app_cus_contact    = app_cus_contact;
                app_cus_main.app_kin_details    = app_kin_details;
                app_cus_main.app_cus_other_info = app_cus_other_info;

                app_cus_main.cus_code = _repository.GetCustomerCode(app_cus_main.id);
                db.app_cus_main.Add(app_cus_main);

                db.Entry(app_cus_main).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.alert = "saved";
                return(RedirectToAction("Index"));
            }
            ViewBag.contact_code      = new SelectList(db.app_cus_contact, "id", "email", app_cus_main.contact_code);
            ViewBag.age_cat_type_code = new SelectList(db.app_age_cate, "id", "name_of_cat", app_cus_main.age_cat_type_code);
            ViewBag.bran_code         = new SelectList(db.app_branch, "id", "branch_name", app_cus_main.bran_code);

            ViewBag.contact_code      = new SelectList(db.app_cus_contact, "id", "email", app_cus_main.contact_code);
            ViewBag.age_cat_type_code = new SelectList(db.app_age_cate, "id", "name_of_cat", app_cus_main.age_cat_type_code);
            ViewBag.bran_code         = new SelectList(db.app_branch, "id", "branch_name", app_cus_main.bran_code);
            //  ViewBag.contact_code = new SelectList(db.app_cus_contact, "id", "tele_number", app_cus_main.age_cat_type_code);
            ViewBag.cus_doc_code     = new SelectList(db.app_cus_doc, "id", "cus_doc_name", app_cus_main.age_cat_type_code);
            ViewBag.cus_other_code   = new SelectList(db.app_cus_other_info, "id", "security_group", app_cus_main.age_cat_type_code);
            ViewBag.cus_type_code    = new SelectList(db.app_cus_type, "id", "type_name", app_cus_main.cus_type_code);
            ViewBag.gender           = new SelectList(db.app_gender, "id", "sex", app_cus_main.gender);
            ViewBag.home_type_code   = new SelectList(db.app_home_type, "id", "type_name", app_cus_main.home_type_code);
            ViewBag.kin_details_code = new SelectList(db.app_kin_details, "id", "full_name", app_cus_main.kin_details_code);
            ViewBag.occupation_code  = new SelectList(db.app_occupation, "id", "name", app_cus_main.occupation_code);
            ViewBag.rel_off_code     = new SelectList(db.app_rel_office, "id", "full_name", app_cus_main.rel_off_code);
            ViewBag.countries        = new SelectList(db.app_countries, "id", "name", app_cus_main.app_cus_contact.contact_code);
            //ViewBag.kin_type = new SelectList(db.app_kin_type, "id", "kin_type_name", app_cus_main.kin_details_code);

            return(View(app_cus_main));
        }
Пример #6
0
        public async Task <ActionResult> CreateCustomer([Bind(Include = "id,citizenship,home_type_code,age_cat_type_code,cus_type_code,title,firstname,lastname,middlename,dob,gender,security_code,occupation_code,img_url,sign_img_url,marital_status,child_num,cus_since,cus_doc_code,credit_limit,kin_type_code,created_by,modified_by,deleted_by,created_date,modified_date,deleted_date,rel_off_code,bran_code")]
                                                        app_cus_main app_cus_main
                                                        , app_cus_other_info app_cus_other_info
                                                        , app_cus_contact app_cus_contact
                                                        , app_gender app_gender
                                                        , app_kin_details app_kin_details

                                                        )
        {
            ViewBag.alert = "";

            var ck = _repository.CheckCustomer(app_cus_main.gender, app_cus_main.firstname, app_cus_main.lastname, app_cus_main.middlename, app_cus_main.dob, app_cus_other_info.verification_id, app_cus_contact.tele_number);


            if (ck)
            {
                ModelState.AddModelError("", "Customer Already exist");
            }



            if (ModelState.IsValid)
            {
                app_cus_main.created_by         = _repository.GetLoginUser();
                app_cus_main.created_date       = _repository.GetCurrentDateTime();
                app_cus_main.cus_since          = _repository.GetCurrentDateTime();
                app_cus_main.img_url            = "/image/photo";
                app_cus_main.status             = "ini";
                app_cus_main.sign_img_url       = "/image/signature";
                app_cus_main.app_cus_contact    = app_cus_contact;
                app_cus_main.app_kin_details    = app_kin_details;
                app_cus_main.app_cus_other_info = app_cus_other_info;

                app_cus_main.cus_code = _repository.GetCustomerCode(app_cus_main.id);
                db.app_cus_main.Add(app_cus_main);
                await db.SaveChangesAsync();

                ViewBag.alert = "saved";
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.alert = "error";
            }

            var errors = ModelState.Values.SelectMany(v => v.Errors);

            ViewBag.citizenship       = new SelectList(db.app_countries, "id", "name");
            ViewBag.home_type_code    = new SelectList(db.app_home_type, "id", "type_name", app_cus_main.home_type_code);
            ViewBag.gender            = new SelectList(db.app_gender, "id", "sex", app_cus_main.gender);
            ViewBag.age_cat_type_code = new SelectList(db.app_age_cate, "id", "name_of_cat", app_cus_main.age_cat_type_code);
            ViewBag.bran_code         = new SelectList(db.app_branch, "id", "branch_name", app_cus_main.bran_code);
            ViewBag.contact_code      = new SelectList(db.app_cus_contact, "id", "tele_number", app_cus_main.contact_code);
            ViewBag.cus_doc_code      = new SelectList(db.app_cus_doc, "id", "cus_doc_name", app_cus_main.cus_doc_code);
            ViewBag.cus_other_code    = new SelectList(db.app_cus_other_info, "id", "cus_other_code", app_cus_main.cus_other_code);
            ViewBag.cus_type_code     = new SelectList(db.app_cus_type, "id", "type_name", app_cus_main.cus_type_code);
            ViewBag.kin_details_code  = new SelectList(db.app_kin_details, "id", "kin_details_code", app_cus_main.kin_details_code);
            ViewBag.occupation_code   = new SelectList(db.app_occupation, "id", "name", app_cus_main.occupation_code);
            ViewBag.rel_off_code      = new SelectList(db.app_rel_office, "id", "full_name", app_cus_main.rel_off_code);
            ViewBag.home_type_code    = new SelectList(db.app_home_type, "id", "type_name");

            return(View(app_cus_main));
        }
Пример #7
0
        public async Task <ActionResult> CreateImport(app_file model)
        {
            //Chcking if modelState is valid or not.
            if (ModelState.IsValid)
            {
                ViewBag.alert = "";
                //Create an object of Service class.
                //---   UploadService service = new UploadService();
                //Saved the uploaded file details to database.
                //---   string fileGuid = service.SaveFileDetails(model);
                //The file is then saved to physical folder.
                string savedFileName = "~/Doc/" + "_" + "000_imp" + model.File.FileName;
                model.File.SaveAs(Server.MapPath(savedFileName));

                //The below code reads the excel file.
                var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;", Server.MapPath(savedFileName));
                var adapter          = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
                var ds = new DataSet();
                adapter.Fill(ds, "results");
                DataTable data = ds.Tables["results"];

                //The excel file is validated for data entered in excel file.
                // bool isValid = _repository.ValidateExcelFileData(data);
                // if (isValid)
                // {
                //If the excel file uploaded validates to true then the data mentioned is saved to database.
                foreach (DataRow row in data.Rows)
                {
                    app_cus_main       app_cus     = new app_cus_main();
                    app_cus_contact    app_contact = new app_cus_contact();
                    app_cus_other_info app_info    = new app_cus_other_info();
                    app_cus_type       app_type    = new app_cus_type();
                    app_occupation     app_occ     = new app_occupation();
                    app_rel_office     app_rel     = new app_rel_office();
                    app_branch         app_bra     = new app_branch();
                    app_gender         app_gen     = new app_gender();


                    app_cus.cus_code   = row["CUST_ID"].ToString();
                    app_cus.title      = row["TITLE"].ToString();
                    app_cus.firstname  = row["FIRST_NAME"].ToString();
                    app_cus.middlename = row["OTHER_NAME"].ToString();
                    app_cus.lastname   = row["LAST_NAME"].ToString();

                    //CUSTOMER TYPE
                    //FK app_cus.cus_type_code = Convert.ToInt32(row["CUSTOMER_TYPE"]);
                    app_type.type_name = row["CUSTOMER_TYPE"].ToString();

                    //GENDER
                    app_gen.sex = row["GENDER"].ToString();

                    app_cus.dob = Convert.ToDateTime(row["DATE_BIRTH"]);

                    //contact
                    app_contact.address2     = row["HOUSE_NUMBER"].ToString();
                    app_contact.tele_number  = row["TEL_1"].ToString();
                    app_contact.tele_number2 = row["TEL_2"].ToString();
                    app_contact.email        = row["EMAIL"].ToString();

                    app_contact.address1 = row["ADDRESS"].ToString();

                    //OTHER INFO
                    app_info.verification_id = row["VERI_ID"].ToString();
                    app_info.security_group  = row["SECURITY_GROUP"].ToString();

                    if (row["SECURITY_GROUP"].ToString() == null || row["SECURITY_GROUP"].ToString() == string.Empty)
                    {
                        app_info.security_group = "Public";
                    }


                    //OCCUPATION
                    //FK app_cus.occupation_code = Convert.ToInt32(row["OCCUPATION"]);


                    app_occ.name = row["OCCUPATION"].ToString();

                    app_cus.marital_status = row["MARITAL_STATUS"].ToString();


                    //relations office
                    // app_cus.rel_off_code = Convert.ToInt32(row["GENDER"]);
                    app_cus.rel_off_code = (int)row["REL_ID"];


                    //app_rel.firstname = row["RELATION_OFFICER_FIRSTNAME"].ToString();
                    //app_rel.lastname = row["RELATION_OFFICER_LASTNAME"].ToString();
                    //app_rel.middlename = row["RELATION_OFFICER_OTHERNAME"].ToString();

                    //BRANCH
                    //FK
                    // app_cus.bran_code =  Convert.ToInt32(row["BRANCH"]);

                    app_bra.branch_name = row["BRANCH"].ToString();


                    //save to db
                    app_cus.created_by   = _repository.GetLoginUser();
                    app_cus.created_date = _repository.GetCurrentDateTime();
                    app_cus.cus_since    = _repository.GetCurrentDateTime();
                    app_cus.img_url      = "/image/photo";
                    app_cus.status       = "ini";
                    app_cus.sign_img_url = "/image/signature";


                    app_cus.app_cus_contact    = app_contact;
                    app_cus.app_cus_other_info = app_info;
                    app_cus.app_cus_type       = app_type;
                    app_cus.app_occupation     = app_occ;
                    app_cus.app_rel_office     = app_rel;
                    app_cus.app_branch         = app_bra;
                    app_cus.app_gender         = app_gen;

                    if (TryValidateModel(app_cus))
                    {
                        var errors = ModelState.Values.SelectMany(v => v.Errors);

                        db.app_cus_main.Add(app_cus);
                        ViewBag.alert = "saved";
                        await db.SaveChangesAsync();
                    }
                    else
                    {
                        var errors = ModelState.Values.SelectMany(v => v.Errors);

                        ViewBag.alert = "error";
                        return(View(app_cus));
                    }

                    //   app_cus_main.cus_code = _repository.GetCustomerCode(app_cus_main.id);

                    //_repository.SaveUserDetails(firstname, lastname, age, email, password);
                }
                return(View("Index"));
                //  _repository.UpdateExcelStatus(Guid.Parse(fileGuid), true, string.Empty);
                // }
                // else
                //  {
                // _repository.UpdateExcelStatus(Guid.Parse(fileGuid), true, "Failure");
                //  }
            }
            else
            {
                return(View(model));
            }
        }