コード例 #1
0
        public override void Save()
        {
            try
            {
                if (grdPostCodes.Rows.Where(c => c.Cells[COLS.Check].Value.ToBool() == true).Count() == 0)
                {
                    ENUtils.ShowMessage("Please select PostCodes");
                    return;
                }

                StringBuilder sb       = new StringBuilder();
                var           listMain = (from a in grdSelectedPostCodes.Rows.OrderBy(C => C.Index)
                                          select new
                {
                    Id = a.Cells[COLS.Id].Value,
                    PostCode = a.Cells[COLS.PostCode].Value
                }).ToList();
                foreach (var item in listMain)
                {
                    sb.Append("insert into PAFDb.dbo.Localization (PostCode,PostCodeId) values ('" + item.PostCode.ToStr() + "'," + item.Id + ");");
                }

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    db.stp_SavePostCodes(sb.ToStr());
                }
                this.Close();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }