Exemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var Id = dgvList.Id;
         if (Id == 0)
         {
             return;
         }
         // If referenced
         //todo: check if exist in ic_item
         // If locked
         var    lInfo = UnitMeasureFacade.GetLock(Id);
         string msg   = "";
         if (lInfo.Locked)
         {
             msg = string.Format(MessageFacade.delete_locked, lInfo.Lock_By, lInfo.Lock_At);
             if (!Privilege.CanAccess(Type.Function_IC_Unit_Measure, "O"))
             {
                 MessageFacade.Show(msg, LabelFacade.sy_delete, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 SessionLogFacade.Log(Type.Priority_Caution, Type.Module_IC_Unit_Measure, Type.Log_Delete, "Cannot delete. Currently locked by '" + lInfo.Lock_By + "' since '" + lInfo.Lock_At + "' . Id=" + dgvList.Id + ", Code=" + txtCode.Text);
                 return;
             }
         }
         // Delete
         msg = MessageFacade.delete_confirmation;
         if (lInfo.Locked)
         {
             msg = string.Format(MessageFacade.lock_currently, lInfo.Lock_By, lInfo.Lock_At) + "'\n" + msg;
         }
         if (MessageFacade.Show(msg, LabelFacade.sy_delete, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
         {
             return;
         }
         try
         {
             UnitMeasureFacade.SetStatus(Id, Type.RecordStatus_Deleted);
         }
         catch (Exception ex)
         {
             MessageFacade.Show(MessageFacade.error_delete + "\r\n" + ex.Message, LabelFacade.sy_delete, MessageBoxButtons.OK, MessageBoxIcon.Error);
             ErrorLogFacade.Log(ex);
         }
         RefreshGrid();
         // log
         SessionLogFacade.Log(Type.Priority_Warning, Type.Module_IC_Unit_Measure, Type.Log_Delete, "Deleted. Id=" + dgvList.Id + ", Code=" + txtCode.Text);
     }
     catch (Exception ex)
     {
         MessageFacade.Show(MessageFacade.error_delete + "\r\n" + ex.Message, LabelFacade.sy_delete, MessageBoxButtons.OK, MessageBoxIcon.Error);
         ErrorLogFacade.Log(ex);
     }
 }
Exemplo n.º 2
0
        private void btnActive_Click(object sender, EventArgs e)
        {
            var Id = dgvList.Id;

            if (Id == 0)
            {
                return;
            }

            string status = btnActive.Text == LabelFacade.sy_button_inactive ? Type.RecordStatus_InActive : Type.RecordStatus_Active;
            // If referenced
            //todo: check if already used in ic_item

            //If locked
            var lInfo = UnitMeasureFacade.GetLock(Id);

            if (lInfo.Locked)
            {
                string msg = string.Format(MessageFacade.lock_currently, lInfo.Lock_By, lInfo.Lock_At);
                if (!Privilege.CanAccess(Type.Function_IC_Unit_Measure, "O"))
                {
                    MessageFacade.Show(msg, MessageFacade.active_inactive, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                if (MessageFacade.Show(msg + "\r\n" + MessageFacade.proceed_confirmation, MessageFacade.active_inactive, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }
            try
            {
                UnitMeasureFacade.SetStatus(Id, status);
            }
            catch (Exception ex)
            {
                MessageFacade.Show(MessageFacade.error_active_inactive + ex.Message, MessageFacade.active_inactive, MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorLogFacade.Log(ex);
            }
            RefreshGrid();
            SessionLogFacade.Log(Type.Priority_Caution, Type.Module_IC_Unit_Measure, status == Type.RecordStatus_InActive ? Type.Log_Inactive : Type.Log_Active, "Id=" + dgvList.Id + ", Code=" + txtCode.Text);
        }