コード例 #1
0
ファイル: dddddd.cs プロジェクト: yh226/SMS_v3.0
        public ActionResult Send(string MessageText, FormCollection collection, bool nullableValue)
        {
            var CompanyList  = db_Company.Companies.ToList();
            var CustomerList = db.Customers.ToList();

            string        selectValueID   = Request.Form["MydropDown"].ToString();
            List <string> MessageFromList = new List <string>();

            MessageFromList.Clear();
            for (int j = 0; j < CompanyList.Count(); j++)
            {
                if (CompanyList[j].Id.ToString().Equals(selectValueID))
                {
                    ci = new CompanyInfor(CompanyList[j].Contact, CompanyList[j].CompanyName);
                    break;
                }
            }


            //for (int j2 = 0; j2 < CustomerList.Count(); j2++)
            //{
            //    for (int j = 0; j < collection.Count; j++)
            //    {
            //        if (CustomerList[j2].Id.ToString() == collection.Keys[j].ToString())
            //        {
            //            MessageFromList.Add(CustomerList[j2].Mobile);
            //            //MessageFromList.Add(CustomerList[j].Mobile);
            //        }
            //    }
            //}

            //for (int j2 = 0; j2 < CustomerList.Count(); j2++)
            //{

            //        if (CustomerList[j2].Id.ToString() == )
            //        {
            //            MessageFromList.Add(CustomerList[j2].Mobile);
            //            //MessageFromList.Add(CustomerList[j].Mobile);
            //        }

            //}

            if (ModelState.IsValid)
            {
                db_DBModels.Open();
                //foreach (string mobile in MessageFromList)
                //{
                string queryInsert = "INSERT INTO MessageOut(MessageTo, MessageText,MessageFrom) " +
                                     "VALUES('" + "2222" + "','" + nullableValue + "','" + ci.getNumber() + "')";
                int i = db_DBModels.DataInsert(queryInsert);
                //}

                db_DBModels.Close();
            }


            return(RedirectToAction("Index", "Customer"));
        }
コード例 #2
0
        public ActionResult SaveDataMessageByGroup(string MessageText)
        {
            var           CompanyList     = db_Company.Companies.ToList();
            var           CustomerList    = db_Customer.Customers.ToList();
            string        selectValueID   = Request.Form["MydropDown"].ToString();
            List <string> MessageFromList = new List <string>();

            MessageFromList.Clear();
            for (int j = 0; j < CompanyList.Count(); j++)
            {
                if (CompanyList[j].Id.ToString().Equals(selectValueID))
                {
                    ci = new CompanyInfor(CompanyList[j].Contact, CompanyList[j].CompanyName);
                    break;
                }
            }

            for (int j2 = 0; j2 < CustomerList.Count(); j2++)
            {
                if (CustomerList[j2].GroupName.Equals(ci.getName()))
                {
                    MessageFromList.Add(CustomerList[j2].Mobile);
                    //MessageFromList.Add(CustomerList[j].Mobile);
                }
            }


            if (ModelState.IsValid)
            {
                db_DBModels.Open();
                foreach (string mobile in MessageFromList)
                {
                    string queryInsert = "INSERT INTO MessageOut(MessageTo, MessageText,MessageFrom) " +
                                         "VALUES('" + mobile + "','" + MessageText + "','" + ci.getNumber() + "')";
                    int i = db_DBModels.DataInsert(queryInsert);
                }

                db_DBModels.Close();
            }

            return(RedirectToAction("Index", "SendMessage"));
        }
コード例 #3
0
        public ActionResult Index(string[] ids, string MessageText)
        {
            var CompanyList  = db_Company.Companies.ToList();
            var CustomerList = db.Customers.ToList();

            List <string> MessageFromList = new List <string>();

            MessageFromList.Clear();

            string selectValueID = Request.Form["MydropDown"].ToString();


            for (int j = 0; j < CompanyList.Count(); j++)
            {
                if (CompanyList[j].Id.ToString().Equals(selectValueID))
                {
                    ci = new CompanyInfor(CompanyList[j].Contact, CompanyList[j].CompanyName);
                    break;
                }
            }



            List <Customer> allCust = new List <Customer>();

            using (CustomerContext dc = new CustomerContext())
            {
                allCust = dc.Customers.OrderBy(a => a.Id).ToList();
            }

            // In the real application you can ids

            if (ids != null)
            {
                ViewBag.Message = "You have selected following Customer ID(s):" + string.Join(", ", ids);
            }
            else
            {
                ViewBag.Message = "No record selected";
            }



            //////send
            if (ModelState.IsValid)
            {
                db_DBModels.Open();
                foreach (string mobile in ids)
                {
                    string queryInsert = "INSERT INTO MessageOut(MessageTo, MessageText,MessageFrom) " +
                                         "VALUES('" + mobile + "','" + MessageText + "','" + ci.getNumber() + "')";
                    int i = db_DBModels.DataInsert(queryInsert);
                }
                db_DBModels.Close();
            }


            return(RedirectToAction("Index", "Customers"));

            /// return View(allCust);
        }