public int Insert(Township township)
        {
            InsertCommand.Parameters["@TownshipName"].Value = township.TownshipName;
            InsertCommand.Parameters["@RegionID"].Value     = township.RegionID;
            InsertCommand.Parameters["@RegionName"].Value   = township.RegionName;
            InsertCommand.Parameters["@Status"].Value       = township.Status;


            int returnValue = -1;

            try
            {
                InsertCommand.Connection.Open();
                returnValue = (int)InsertCommand.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                InsertCommand.Connection.Close();
            }
            return(returnValue);
        }
Example #2
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Name,RegionId")] Township township)
        {
            if (id != township.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(township);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TownshipExists(township.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(township));
        }
Example #3
0
        public void InsertUpdateDelete()
        {
            TownshipController townshipController = new TownshipController();

            //create new entity
            Township township = new Township();

            township.townshipId   = Guid.NewGuid();
            township.name         = "Test Name";
            township.entryDate    = DateTime.Now;
            township.appUserId    = Guid.NewGuid();
            township.modifiedDate = DateTime.Now;
            township.remark       = "Test Remark";

            //insert
            var result1 = townshipController.Post(township);
            //update
            var result2 = townshipController.Post(township);
            //delete
            var result3 = townshipController.Delete(township.townshipId);

            //assert
            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsTrue(result1 is OkResult);
            Assert.IsTrue(result2 is OkResult);
            Assert.IsTrue(result3 is OkResult);
        }
        public int Update(Township township)
        {
            UpdateCommand.Parameters["@ID"].Value           = township.ID;
            UpdateCommand.Parameters["@TownshipName"].Value = township.TownshipName;
            UpdateCommand.Parameters["@RegionID"].Value     = township.RegionID;
            UpdateCommand.Parameters["@RegionName"].Value   = township.RegionName;
            UpdateCommand.Parameters["@Status"].Value       = township.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
Example #5
0
        public void DeletedByTownship(Township t)
        {
            Township township = mBMSEntities.Townships.Where(x => x.TownshipID == t.TownshipID).SingleOrDefault();

            township.Active        = t.Active;
            township.DeletedDate   = DateTime.Now;
            township.DeletedUserID = t.DeletedUserID;
            mBMSEntities.SaveChanges();
        }
Example #6
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(Direction.GetHashCode() ^
            LegalSubdivision.GetHashCode() ^
            Meridian.GetHashCode() ^
            Range.GetHashCode() ^
            Section.GetHashCode() ^
            Township.GetHashCode());
 }
Example #7
0
        public async Task <IActionResult> Create([Bind("Id,Name,RegionId")] Township township)
        {
            if (ModelState.IsValid)
            {
                _context.Add(township);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(township));
        }
Example #8
0
 private void dgvTownship_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
 {
     foreach (DataGridViewRow row in dgvTownship.Rows)
     {
         Township township = (Township)row.DataBoundItem;
         row.Cells[0].Value = township.TownshipID;
         row.Cells[1].Value = township.TownshipCode;
         row.Cells[2].Value = township.TownshipNameInEng;
         row.Cells[3].Value = township.TownshipNameInMM;
     }
 }
        private Township DataTableToEntity(DataTable dt)
        {
            Township township = new Township();

            if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0)
            {
                if (Null.IsNotNull(dt.Rows[0]))
                {
                    DataRow dr = dt.Rows[0];
                    if (Null.IsNotNull(dr["ID"]))
                    {
                        township.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        township.ID = 0;
                    }
                    if (Null.IsNotNull(dr["TownshipName"]))
                    {
                        township.TownshipName = Convert.ToString(dr["TownshipName"]);
                    }
                    else
                    {
                        township.TownshipName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["RegionID"]))
                    {
                        township.RegionID = Convert.ToInt32(dr["RegionID"]);
                    }
                    else
                    {
                        township.RegionID = 0;
                    }
                    if (Null.IsNotNull(dr["RegionName"]))
                    {
                        township.RegionName = Convert.ToString(dr["RegionName"]);
                    }
                    else
                    {
                        township.RegionName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        township.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        township.Status = string.Empty;
                    }
                }
            }
            return(township);
        }
Example #10
0
        public void UpdatedByTownshipID(Township t)
        {
            Township township = mBMSEntities.Townships.Where(x => x.TownshipID == t.TownshipID).SingleOrDefault();

            township.TownshipNameInEng = t.TownshipNameInEng;
            township.TownshipNameInMM  = t.TownshipNameInMM;
            township.TownshipCode      = t.TownshipCode;
            township.UpdatedUserID     = t.UpdatedUserID;
            township.UpdatedDate       = DateTime.Now;
            mBMSEntities.Townships.AddOrUpdate(township); //requires using System.Data.Entity.Migrations;
            mBMSEntities.SaveChanges();
        }
Example #11
0
        public ActionResult AccountForApproval(string pageNumber)
        {
            if (Session["account"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (Session["accountRole"].Equals("0"))
                {
                    return(RedirectToAction("AllPosts", "Posts"));
                }
            }
            int pageN = 1;

            if (pageNumber != null)
            {
                pageN = Int32.Parse(pageNumber);
            }
            var listAccountManagerModel = new List <AccountManagerModel>();
            var listAllAccount          = db.Accounts.Where(p => p.AccountStatusID == 2).ToList();
            var listAccount             = listAllAccount.Skip((pageN - 1) * pageSize).Take(pageSize).ToList();

            foreach (var item in listAccount)
            {
                var      accountInfo   = db.Infoes.SingleOrDefault(p => p.AccountID == item.AccountID);
                var      accountStatus = db.AccountStatus.SingleOrDefault(p => p.AccountStatusID == item.AccountStatusID);
                City     city          = null;
                Township township      = null;
                if (accountInfo != null)
                {
                    city     = db.Cities.SingleOrDefault(p => p.CityID == accountInfo.CityID);
                    township = db.Townships.SingleOrDefault(p => p.TownshipID == accountInfo.TownshipID);
                }

                var accountManagerModelItem = new AccountManagerModel()
                {
                    Account       = item,
                    AccountStatus = accountStatus,
                    AccountInfo   = accountInfo,
                    City          = city,
                    TownShip      = township
                };
                listAccountManagerModel.Add(accountManagerModelItem);
            }
            var subTotalPage = listAllAccount.Count / pageSize;
            var totalPage    = (listAllAccount.Count % pageSize == 0) ? subTotalPage : subTotalPage + 1;

            ViewBag.PageNumber = pageN;
            ViewBag.TotalPage  = totalPage;
            return(View(listAccountManagerModel));
        }
Example #12
0
        public void bindTownship()
        {
            List <Township> townshipList = new List <Township>();
            Township        township     = new Township();

            township.TownshipID        = Convert.ToString(0);
            township.TownshipNameInEng = "Select";
            townshipList.Add(township);
            townshipList.AddRange(mbsEntities.Townships.Where(x => x.Active == true).ToList());
            cboTownshipName.DataSource    = townshipList;
            cboTownshipName.DisplayMember = "TownshipNameInEng";
            cboTownshipName.ValueMember   = "TownshipID";
        }
Example #13
0
        public async Task <SaveTownshipResponse> SaveAsync(Township township)
        {
            try {
                await _townshipRepository.AddAsync(township);

                await _unitOfWork.CompleteAsync();

                return(new SaveTownshipResponse(township));
            } catch (Exception ex) {
                // Do some logging stuff
                return(new SaveTownshipResponse($"An error occurred when saving the tasked: {ex.Message}"));
            }
        }
Example #14
0
 private void dgvTownship_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == 5)
         {
             //DeleteForTownship
             DialogResult result = MessageBox.Show(this, "Are you sure you want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
             if (result.Equals(DialogResult.OK))
             {
                 DataGridViewRow row         = dgvTownship.Rows[e.RowIndex];
                 Township        townshipObj = (Township)row.DataBoundItem;
                 townshipObj = (from t in mbmsEntities.Townships where t.TownshipID == townshipObj.TownshipID select t).FirstOrDefault();
                 var quarterCount  = (from t in townshipObj.Quarters where t.Active == true select t).Count();
                 var customerCount = (from t in townshipObj.Customers where t.Active == true select t).Count();
                 if (quarterCount > 0)
                 {
                     MessageBox.Show("This Township cannot be deleted! It is in used.", "Cannot Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
                 if (customerCount > 0)
                 {
                     MessageBox.Show("This Township cannot be deleted! It is in used.", "Cannot Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
                 TownshipID             = Convert.ToString(row.Cells[0].Value);
                 dgvTownship.DataSource = "";
                 Township township = (from t in mbmsEntities.Townships where t.TownshipID == TownshipID select t).FirstOrDefault();
                 township.Active        = false;
                 township.DeletedUserID = UserID;
                 township.DeletedDate   = DateTime.Now;
                 townshipController.DeletedByTownship(township);
                 dgvTownship.DataSource = (from t in mbmsEntities.Townships where t.Active == true orderby t.TownshipCode descending select t).ToList();
                 MessageBox.Show(this, "Successfully Deleted!", "Delete Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Clear();
                 FormRefresh();
             }
         }
         else if (e.ColumnIndex == 4)
         {
             //EditTownship
             DataGridViewRow row = dgvTownship.Rows[e.RowIndex];
             TownshipID              = Convert.ToString(row.Cells[0].Value);
             txtTownshipCode.Text    = Convert.ToString(row.Cells[1].Value);
             txtTownshipNameEng.Text = Convert.ToString(row.Cells[2].Value);
             txtTowsshipNameMM.Text  = Convert.ToString(row.Cells[3].Value);
             isEdit       = true;
             btnSave.Text = "Update";
         }
     }
 }
Example #15
0
 public IActionResult Post([FromBody] Township value)
 {
     try
     {
         using (var db = My.ConnectionFactory())
         {
             int result = db.Execute($@"IF EXISTS({My.Table_Township.SelectSingle}) {My.Table_Township.Update} ELSE {My.Table_Township.Insert}", value);
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public void DeleteTownshipByTownshipID(TownshipInfo TownInfo)
 {
     try
     {
         using (RMSDataContext db = new RMSDataContext())
         {
             var obj = (from a in db.Townships where a.TownshipID == TownInfo.TownshipID select a).First();
             db.Townships.DeleteOnSubmit(obj);
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         Township tbl = new Township();
     }
 }
Example #17
0
        public override void Create(TownshipViewModel viewModel, string userId)
        {
            var newTownship = new Township
            {
                Id     = viewModel.Id,
                Name   = viewModel.Name,
                CityId = viewModel.CityId
            };

            newTownship.CreatedDate   = newTownship.UpdatedDate = DateTime.Now; //multi variable assignment
            newTownship.CreatedUserId = newTownship.UpdatedUserId = userId;
            newTownship.Version       = 1;

            _context.Townships.Add(newTownship);
            _context.SaveChanges();
        }
Example #18
0
        public override string ToString()
        {
            string Output;

            Output  = Township.ToString();
            Output += "," + Range.ToString();
            Output += "," + RangeDirection.Direction;
            Output += "," + Section;
            Output += "," + SubSection.ToString();
            Output += "," + Footage.NorthSouthValueFeet.ToString("0000");
            Output += "," + Footage.NSDir.Direction;
            Output += "," + Footage.EastWestValueFeet.ToString("0000");
            Output += "," + Footage.EWDir.Direction;
            Output += "," + Point.Latitude.ToString("00.00000000");
            Output += "," + Point.Longitude.ToString("000.00000000");
            return(Output);
        }
        public async Task <IActionResult> PostAsync([FromBody] Township township)
        {        // if Model is invalid show error message by using ModelState
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            //otherwise data save in database

            var result = await _townshipService.SaveAsync(township);

            //if result is not success show error Message
            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }


            return(Ok());
        }
 public void UpdateTownshipByTownshipID(TownshipInfo TownInfo)
 {
     try
     {
         using (RMSDataContext db = new RMSDataContext())
         {
             var obj = (from a in db.Townships where a.TownshipID == TownInfo.TownshipID select a).First();
             obj.TownshipID           = TownInfo.TownshipID;
             obj.Township_Name        = TownInfo.TownshipName;
             obj.Township_Description = TownInfo.TownshipDescription;
             obj.CityID = TownInfo.CityID;
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         Township tbl = new Township();
     }
 }
        public async Task <IActionResult> PutAsync(int id, [FromBody] Township resource)
        {        // if Model is invalid show error message by using ModelState
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            //get data form EmployeeAttendenceResource by id using AutoMapper
            //var tasked=_mapper.Map<SaveTaskedResource,Tasked>(resource);
            //update data by id
            var result = await _townshipService.UpdateAsync(id, resource);

            //if updated data is null
            if (result == null)
            {
                return(BadRequest(result));
            }
            //get result data from SaveEmployeeResource after update data using automapper
            var taskedResource = _mapper.Map <Township, TownShipResourse>(result.TownShip);

            //show data
            return(Ok(taskedResource));
        }
Example #22
0
        public async Task <SaveTownshipResponse> UpdateAsync(int id, Township township)
        {
            //throw new NotImplementedException();
            var existingTownship = await _townshipRepository.FindByIdAsync(id);

            if (existingTownship == null)
            {
                return(new SaveTownshipResponse("Tasked not found."));
            }

            existingTownship.Name      = township.Name;
            existingTownship.city.Name = township.city.Name;

            try {
                _townshipRepository.Update(existingTownship);
                await _unitOfWork.CompleteAsync();

                return(new SaveTownshipResponse(existingTownship));
            } catch (Exception ex) {
                // Do some logging stuff
                return(new SaveTownshipResponse($"An error occurred when updating the tasked: {ex.Message}"));
            }
        }
 private SaveTownshipResponse(bool success, string message, Township townShip) : base(success, message)
 {
     TownShip = townShip;
 }
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="rate">Saved shipping.</param>
 /// <returns>Response.</returns>
 public SaveTownshipResponse(Township township) : this(true, string.Empty, township)
 {
     TownShip = township;
 }
Example #25
0
 public void Update(Township township)
 {
     _context.Townships.Update(township);
 }
Example #26
0
 public void Remove(Township township)
 {
     _context.Townships.Remove(township);
 }
Example #27
0
 public async Task AddAsync(Township township)
 {
     await _context.Townships.AddAsync(township);
 }
Example #28
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (checkValidation())
            {
                if (isEdit)
                {
                    int editTownshipCodeCount = 0, editTownshipNameEngCount = 0, editTownshipNameMM = 0;

                    Township updateTownship = (from t in mbmsEntities.Townships where t.TownshipID == TownshipID select t).FirstOrDefault();
                    if (txtTownshipCode.Text != updateTownship.TownshipCode)
                    {
                        editTownshipCodeCount = (from t in mbmsEntities.Townships where (t.TownshipCode == txtTownshipCode.Text) && t.Active == true select t).ToList().Count;
                    }
                    if (txtTownshipNameEng.Text != updateTownship.TownshipNameInEng)
                    {
                        editTownshipNameEngCount = (from t in mbmsEntities.Townships where (t.TownshipNameInEng == txtTownshipNameEng.Text) && t.Active == true select t).ToList().Count;
                    }
                    if (txtTowsshipNameMM.Text != updateTownship.TownshipNameInMM)
                    {
                        editTownshipNameMM = (from t in mbmsEntities.Townships where (t.TownshipNameInMM == txtTowsshipNameMM.Text) && t.Active == true select t).ToList().Count;
                    }

                    if (editTownshipCodeCount > 0)
                    {
                        tooltip.SetToolTip(txtTownshipCode, "Error");
                        tooltip.Show("Township Code is already exist!", txtTownshipCode);
                        return;
                    }
                    if (editTownshipNameEngCount > 0)
                    {
                        tooltip.SetToolTip(txtTownshipNameEng, "Error");
                        tooltip.Show("Township Name is already exist!", txtTownshipNameEng);
                        return;
                    }
                    if (editTownshipNameEngCount > 0)
                    {
                        tooltip.SetToolTip(txtTowsshipNameMM, "Error");
                        tooltip.Show("Township Name is already exist!", txtTowsshipNameMM);
                        return;
                    }
                    updateTownship.TownshipCode      = txtTownshipCode.Text;
                    updateTownship.TownshipNameInEng = txtTownshipNameEng.Text;
                    updateTownship.TownshipNameInMM  = txtTowsshipNameMM.Text;
                    updateTownship.UpdatedUserID     = UserID;
                    updateTownship.UpdatedDate       = DateTime.Now;
                    townshipController.UpdatedByTownshipID(updateTownship);
                    MessageBox.Show("Successfully updated Township!", "Update");
                    isEdit       = false;
                    btnSave.Text = "Save";
                    Clear();
                    FormRefresh();
                }
                else
                {
                    Township township = new Township();
                    int      townshipCodeCount = 0, townshipNameEng = 0, townshipNameMM = 0;
                    townshipCodeCount = (from t in mbmsEntities.Townships where t.TownshipCode == txtTownshipCode.Text && t.Active == true select t).ToList().Count;
                    townshipNameEng   = (from t in mbmsEntities.Townships where t.TownshipNameInEng == txtTownshipNameEng.Text && t.Active == true select t).ToList().Count;
                    townshipNameMM    = (from t in mbmsEntities.Townships where t.TownshipNameInMM == txtTowsshipNameMM.Text && t.Active == true select t).ToList().Count;

                    if (townshipCodeCount > 0)
                    {
                        tooltip.SetToolTip(txtTownshipCode, "Error");
                        tooltip.Show("Township Code is already exist!", txtTownshipCode);
                        return;
                    }
                    if (townshipNameEng > 0)
                    {
                        tooltip.SetToolTip(txtTownshipNameEng, "Error");
                        tooltip.Show("Township Name is already exist!", txtTownshipNameEng);
                        return;
                    }
                    if (townshipNameMM > 0)
                    {
                        tooltip.SetToolTip(txtTowsshipNameMM, "Error");
                        tooltip.Show("Township Name is already exist!", txtTowsshipNameMM);
                        return;
                    }
                    township.TownshipID        = Guid.NewGuid().ToString();
                    township.TownshipCode      = txtTownshipCode.Text;
                    township.TownshipNameInEng = txtTownshipNameEng.Text;
                    township.TownshipNameInMM  = txtTowsshipNameMM.Text;
                    township.Active            = true;
                    township.CreatedUserID     = UserID;
                    township.CreatedDate       = DateTime.Now;
                    townshipController.Save(township);
                    MessageBox.Show("Successfully registered Township! Please check it in'Township List'.", "Save Success");
                    Clear();
                    FormRefresh();
                }
            }
        }
Example #29
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dt.Rows.Count > 0)
            {
                DialogResult ok = MessageBox.Show("are you sure to save data?", "information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (ok == DialogResult.Yes)
                {
                    List <Customer> customerList = new List <Customer>();
                    foreach (DataRow row in dt.Rows)
                    {
                        bool isdataexit = iCustomerServices.GetCustomerCustomerCode(row["CustomerCode"].ToString());
                        if (isdataexit)
                        {
                            MessageBox.Show("Customer  data already exists in the system for>" + row["CustomerCode"].ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        bool IsSMDSerialNoExist = iCustomerServices.GetCustomerBySMDNo(row["SMDNo"].ToString());
                        if (IsSMDSerialNoExist)
                        {
                            MessageBox.Show("Customer  SMD Serial No already exists in the system for>" + row["CustomerCode"].ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        Customer customerEntity = new Customer();
                        customerEntity.CustomerCode      = row["CustomerCode"].ToString();
                        customerEntity.CustomerID        = Guid.NewGuid().ToString();
                        customerEntity.SMDNo             = row["SMDNo"].ToString();
                        customerEntity.CustomerNameInEng = row["CustomerNameInEng"].ToString();
                        customerEntity.CustomerNameInMM  = row["CustomerNameInMM"].ToString();
                        customerEntity.NRC     = row["NRC"].ToString();
                        customerEntity.PhoneNo = row["PhoneNo"].ToString();
                        customerEntity.Post    = row["PostalCode"].ToString();
                        Township t = iCustomerServices.GetTownshipByTownshipCode(row["TownshipCode"].ToString());
                        if (t == null)
                        {
                            MessageBox.Show("Please define Township Code for>" + customerEntity.CustomerCode, "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        customerEntity.TownshipID = t.TownshipID;
                        customerEntity.Township   = t;
                        Quarter q = iCustomerServices.GetQuarterByQarterCode(row["QuarterCode"].ToString());
                        if (q == null)
                        {
                            MessageBox.Show("Please define Quarter Code  for>" + customerEntity.CustomerCode, "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        customerEntity.QuarterID            = q.QuarterID;
                        customerEntity.Quarter              = q;
                        customerEntity.CustomerAddressInEng = row["Address(English)"].ToString();
                        customerEntity.CustomerAddressInMM  = row["Address(Myanmar)"].ToString();
                        Meter m = iCustomerServices.GetMeterByQarterNo(row["MeterNo"].ToString());
                        if (m == null)
                        {
                            MessageBox.Show("Please define MeterNo data for>" + customerEntity.CustomerCode, "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        bool IsMeterIDExitsin = iCustomerServices.GetCustomerByMeterID(m.MeterBoxID);
                        if (IsMeterIDExitsin)
                        {
                            MessageBox.Show("Customer  Meter No already exists in the system for>" + row["CustomerCode"].ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        customerEntity.MeterID = m.MeterBoxID;
                        customerEntity.Meter   = m;

                        Ledger l = iCustomerServices.GetLedgerByLedgerCode(Convert.ToInt32(row["LedgerCode"].ToString()));
                        if (l == null)
                        {
                            MessageBox.Show("Please define Ledger Code data for>" + customerEntity.CustomerCode, "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        customerEntity.Ledger   = l;
                        customerEntity.LedgerID = l.LedgerID;
                        customerEntity.PageNo   = Convert.ToInt16(row["PageNo"].ToString());
                        customerEntity.LineNo   = Convert.ToInt16(row["LineNo"].ToString());
                        BillCode7Layer b = iCustomerServices.GetBillCode7LayerByBillCodeNo(Convert.ToInt32(row["BillCodeNo"].ToString()));
                        if (b == null)
                        {
                            MessageBox.Show("Please define Bill Code No data for>" + customerEntity.CustomerCode, "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        customerEntity.BillCode7LayerID = b.BillCode7LayerID;
                        customerEntity.BillCode7Layer   = b;
                        customerEntity.Active           = true;
                        customerEntity.CreatedDate      = DateTime.Now;
                        customerEntity.CreatedUserID    = UserID;
                        customerList.Add(customerEntity);
                    }
                    if (customerList.Count > 0)
                    {
                        try {
                            iCustomerServices.SaveRange(customerList);
                            MessageBox.Show("Importing Customer data is successfylly saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex) {
                            MessageBox.Show("Error occur :(", "information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                } //end of yes dialog
            }     //end of dt.Rows.Count>0
        }
Example #30
0
 public override string ToString()
 {
     return(Province?.ToString() + Prefecture?.ToString() + County?.ToString()
            + Township?.ToString() + Village?.ToString() + ResidentialGroup?.ToString()
            + Detail);
 }