Exemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (country == null)
     {
         Country newCountry = new Country();
         newCountry = fillObject(newCountry);
         if (newCountry != null)
         {
             var registered = _countryService.Insert(newCountry);
             if (registered)
             {
                 MessageBox.Show("U regjistrua me sukses");
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Regjistrimi deshtoi. Ju lutem kontrolloni formen");
             }
         }
     }
     else
     {
         country = fillObject(country);
         var updated = _countryService.Update(country);
         if (updated)
         {
             MessageBox.Show("U editua me sukses");
             this.Close();
         }
         else
         {
             MessageBox.Show("Editimi deshtoi. Ju lutem kontrolloni formen");
         }
     }
 }
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    CountryBLL countryBLL = new CountryBLL();
                    DataTable  dt         = countryBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string    actionStatus = "Updated";
                            Countries country      = new Countries();
                            country.CountryId         = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"]));
                            country.CountryCode       = Convert.ToString(dt.Rows[0]["CountryCode"]);
                            country.Name              = Convert.ToString(dt.Rows[0]["Name"]);
                            country.CountryCodeAlpha2 = Convert.ToString(dt.Rows[0]["CountryCodeAlpha2"]);
                            country.CountryCodeAlpha3 = Convert.ToString(dt.Rows[0]["CountryCodeAlpha3"]);
                            country.Description       = Convert.ToString(dt.Rows[0]["Description"]);
                            country.IsActive          = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            country.CreatedDate       = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            country.CreatedBy         = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            country.CreatedFrom       = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                            country.UpdatedDate = DateTime.Now;
                            country.UpdatedBy   = UserInfo;
                            country.UpdatedFrom = StationInfo;

                            if (country.IsActive)
                            {
                                country.IsActive = false;
                                actionStatus     = "Deactivated";
                            }
                            else
                            {
                                country.IsActive = true;
                                actionStatus     = "Activated";
                            }

                            if (countryBLL.Update(country))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }
Exemplo n.º 3
0
        private void SaveAndUpdate()
        {
            try
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    Alert(AlertType.Warning, "Enter country name.");
                    txtName.Focus();
                }
                else
                {
                    string name = Convert.ToString(txtName.Text);
                    string countryCodeAlpha2 = Convert.ToString(txtCountryCodeAlpha2.Text);
                    string countryCodeAlpha3 = Convert.ToString(txtCountryCodeAlpha3.Text);
                    string description       = Convert.ToString(txtDescription.Text);

                    CountryBLL countryBLL = new CountryBLL();
                    if (this.ModelId > 0)
                    {
                        DataTable dt      = countryBLL.GetById(this.ModelId);
                        Countries country = new Countries();
                        country.CountryId         = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"]));
                        country.CountryCode       = Convert.ToString(dt.Rows[0]["CountryCode"]);
                        country.Name              = Convert.ToString(dt.Rows[0]["Name"]);
                        country.CountryCodeAlpha2 = Convert.ToString(dt.Rows[0]["CountryCodeAlpha2"]);
                        country.CountryCodeAlpha3 = Convert.ToString(dt.Rows[0]["CountryCodeAlpha3"]);
                        country.Description       = Convert.ToString(dt.Rows[0]["Description"]);
                        country.IsActive          = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                        country.CreatedDate       = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                        country.CreatedBy         = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                        country.CreatedFrom       = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                        country.Name = name.Trim();
                        country.CountryCodeAlpha2 = countryCodeAlpha2;
                        country.CountryCodeAlpha3 = countryCodeAlpha3;
                        country.Description       = description;

                        country.UpdatedDate = DateTime.Now;
                        country.UpdatedBy   = this.UserInfo;
                        country.UpdatedFrom = this.StationInfo;

                        if (countryBLL.Update(country))
                        {
                            this.MultiEntryDisallow = true;
                            Alert(AlertType.Success, "Updated successfully.");
                            ClearFields();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to update.");
                        }
                    }
                    else
                    {
                        Countries country = new Countries();
                        country.CountryCode       = this.ModelCode;
                        country.Name              = name.Trim();
                        country.CountryCodeAlpha2 = countryCodeAlpha2;
                        country.CountryCodeAlpha3 = countryCodeAlpha3;
                        country.Description       = description;
                        country.IsActive          = true;
                        country.CreatedDate       = DateTime.Now;
                        country.CreatedBy         = this.UserInfo;
                        country.CreatedFrom       = this.StationInfo;

                        if (countryBLL.Save(country))
                        {
                            Alert(AlertType.Success, "Saved successfully.");
                            ClearFields();
                            GenerateCode();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to save.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Alert(AlertType.Error, ex.Message.ToString());
            }
        }
Exemplo n.º 4
0
 static public int Update(int id, string name)
 {
     return(CountryBLL.Update(id, name));
 }
Exemplo n.º 5
0
        private SaveResult SaveEdit(CountryViewModel oCountry)
        {
            CountryBLL cb = new CountryBLL();

            return(cb.Update(oCountry, UserId, UserName));
        }