Exemple #1
0
 private void Edit(int id)
 {
     try
     {
         GuideBLL  guideBLL = new GuideBLL();
         DataTable dt       = guideBLL.GetById(id);
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 this.ModelId              = Convert.ToInt32(Convert.ToString(dt.Rows[0]["GuideId"]));
                 this.ModelCode            = Convert.ToString(dt.Rows[0]["GuideCode"]);
                 txtName.Text              = Convert.ToString(dt.Rows[0]["Name"]);
                 txtContactNumber.Text     = Convert.ToString(dt.Rows[0]["ContactNumber"]);
                 txtAddressLine1.Text      = Convert.ToString(dt.Rows[0]["AddressLine1"]);
                 txtAddressLine2.Text      = Convert.ToString(dt.Rows[0]["AddressLine2"]);
                 txtEmail.Text             = Convert.ToString(dt.Rows[0]["Email"]);
                 ddlLocation.SelectedValue = Convert.ToString(dt.Rows[0]["LocationId"]);
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to edit.");
     }
 }
Exemple #2
0
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    GuideBLL  guideBLL = new GuideBLL();
                    DataTable dt       = guideBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string actionStatus = "Updated";
                            Guides guide        = new Guides();
                            guide.GuideId       = Convert.ToInt32(Convert.ToString(dt.Rows[0]["GuideId"]));
                            guide.GuideCode     = Convert.ToString(dt.Rows[0]["GuideCode"]);
                            guide.Name          = Convert.ToString(dt.Rows[0]["Name"]);
                            guide.ContactNumber = Convert.ToString(dt.Rows[0]["ContactNumber"]);
                            guide.Email         = Convert.ToString(dt.Rows[0]["Email"]);
                            guide.AddressLine1  = Convert.ToString(dt.Rows[0]["AddressLine1"]);
                            guide.AddressLine2  = Convert.ToString(dt.Rows[0]["AddressLine2"]);
                            guide.IsActive      = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            guide.CreatedDate   = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            guide.CreatedBy     = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            guide.CreatedFrom   = Convert.ToString(dt.Rows[0]["CreatedFrom"]);
                            guide.LocationId    = Convert.ToInt32(dt.Rows[0]["LocationId"]);

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

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

                            if (guideBLL.Update(guide))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }
Exemple #3
0
        private void SaveAndUpdate()
        {
            try
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    Alert(AlertType.Warning, "Enter name.");
                    txtName.Focus();
                }
                else if (string.IsNullOrEmpty(txtContactNumber.Text))
                {
                    Alert(AlertType.Warning, "Enter contact number.");
                    txtContactNumber.Focus();
                }
                else if (string.IsNullOrEmpty(txtAddressLine1.Text))
                {
                    Alert(AlertType.Warning, "Enter address line 1.");
                    txtAddressLine1.Focus();
                }
                else if (ddlLocation.SelectedIndex < 1)
                {
                    Alert(AlertType.Warning, "Select location.");
                    ddlLocation.Focus();
                }
                else
                {
                    QuaintLibraryManager lib = new QuaintLibraryManager();
                    string Name          = Convert.ToString(txtName.Text);
                    string contactNumber = Convert.ToString(txtContactNumber.Text);
                    string email         = Convert.ToString(txtEmail.Text);
                    string addressLine1  = Convert.ToString(txtAddressLine1.Text);
                    string addressLine2  = Convert.ToString(txtAddressLine2.Text);
                    int    locationId    = Convert.ToInt32(ddlLocation.SelectedValue);

                    GuideBLL guideBLL = new GuideBLL();
                    if (this.ModelId > 0)
                    {
                        DataTable dt    = guideBLL.GetById(this.ModelId);
                        Guides    guide = new Guides();
                        guide.GuideId       = Convert.ToInt32(Convert.ToString(dt.Rows[0]["GuideId"]));
                        guide.GuideCode     = Convert.ToString(dt.Rows[0]["GuideCode"]);
                        guide.Name          = Convert.ToString(dt.Rows[0]["Name"]);
                        guide.ContactNumber = Convert.ToString(dt.Rows[0]["ContactNumber"]);
                        guide.Email         = Convert.ToString(dt.Rows[0]["Email"]);
                        guide.AddressLine1  = Convert.ToString(dt.Rows[0]["AddressLine1"]);
                        guide.AddressLine2  = Convert.ToString(dt.Rows[0]["AddressLine2"]);
                        guide.IsActive      = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                        guide.CreatedDate   = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                        guide.CreatedBy     = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                        guide.CreatedFrom   = Convert.ToString(dt.Rows[0]["CreatedFrom"]);
                        guide.LocationId    = Convert.ToInt32(Convert.ToString(dt.Rows[0]["LocationId"]));

                        guide.Name          = Name;
                        guide.ContactNumber = contactNumber;
                        guide.Email         = email;
                        guide.AddressLine1  = addressLine1;
                        guide.AddressLine2  = addressLine2;
                        guide.LocationId    = locationId;

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

                        if (guideBLL.Update(guide))
                        {
                            this.MultiEntryDisallow = true;
                            Alert(AlertType.Success, "Updated successfully.");
                            ClearFields();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to update.");
                        }
                    }
                    else
                    {
                        Guides guide = new Guides();
                        guide.GuideCode     = this.ModelCode;
                        guide.Name          = Name;
                        guide.ContactNumber = contactNumber;
                        guide.Email         = email;
                        guide.AddressLine1  = addressLine1;
                        guide.AddressLine2  = addressLine2;
                        guide.IsActive      = true;
                        guide.CreatedDate   = DateTime.Now;
                        guide.CreatedBy     = this.UserInfo;
                        guide.CreatedFrom   = this.StationInfo;
                        guide.LocationId    = locationId;

                        if (guideBLL.Save(guide))
                        {
                            Alert(AlertType.Success, "Saved successfully.");
                            ClearFields();
                            GenerateCode();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to save.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Alert(AlertType.Error, ex.Message.ToString());
            }
        }