コード例 #1
0
        private void AddTravelExpenses(TravelExpMovTypesEnum pEnumMovType, int pIntRepeat, int pIntDays = 1)
        {
            try
            {
                for (int i = 0; i < pIntRepeat; i++)
                {
                    dtTravelExp.Rows.Add();
                    dtTravelExp.SetValue("#", dtTravelExp.Rows.Count - 1, dtTravelExp.Rows.Count);
                    dtTravelExp.SetValue("Commts", dtTravelExp.Rows.Count - 1, string.Empty);
                    dtTravelExp.SetValue("TravDays", dtTravelExp.Rows.Count - 1, mIntDaysTotal);

                    if (TravelExpMovTypesEnum.IsDayExpensesType(pEnumMovType)) //operadores
                    {
                        dtTravelExp.SetValue("EmpCode", dtTravelExp.Rows.Count - 1, (mDtEmployees.GetValue(1, i).ToString() == "0") ? mStrSupervisorCode : mDtEmployees.GetValue(1, i));
                        dtTravelExp.SetValue("EmpName", dtTravelExp.Rows.Count - 1, string.IsNullOrEmpty(mDtEmployees.GetValue(2, i).ToString()) ? mStrSupervisorName : mDtEmployees.GetValue(2, i));
                        dtTravelExp.SetValue("AcctCode", dtTravelExp.Rows.Count - 1, mStrExpDayAcct);
                        dtTravelExp.SetValue("TravPrice", dtTravelExp.Rows.Count - 1, mDblExpDayPrice);
                        dtTravelExp.SetValue("TravImp", dtTravelExp.Rows.Count - 1, mIntDaysTotal * mDblExpDayPrice);
                        dtTravelExp.SetValue("EmpType", dtTravelExp.Rows.Count - 1, EmployeesTypesEnum.Operators.GetDescription());
                        dtTravelExp.SetValue("MovType", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.DayExpenses.Description);
                        dtTravelExp.SetValue("MovCode", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.DayExpenses.Value);
                    }
                    else if (TravelExpMovTypesEnum.IsTravelExpensesType(pEnumMovType)) //supervisor
                    {
                        dtTravelExp.SetValue("EmpCode", dtTravelExp.Rows.Count - 1, mStrSupervisorCode);
                        dtTravelExp.SetValue("EmpName", dtTravelExp.Rows.Count - 1, mStrSupervisorName);
                        dtTravelExp.SetValue("AcctCode", dtTravelExp.Rows.Count - 1, mStrViaticExpAcct);
                        dtTravelExp.SetValue("TravPrice", dtTravelExp.Rows.Count - 1, mDblViaticPrice);
                        dtTravelExp.SetValue("TravImp", dtTravelExp.Rows.Count - 1, mIntDaysTotal * mDblViaticPrice);
                        dtTravelExp.SetValue("EmpType", dtTravelExp.Rows.Count - 1, EmployeesTypesEnum.Supervisors.GetDescription());
                        dtTravelExp.SetValue("MovType", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.TravelExpenses.Description);
                        dtTravelExp.SetValue("MovCode", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.TravelExpenses.Value);
                    }
                    else if (TravelExpMovTypesEnum.IsMinorExpensesType(pEnumMovType)) //supervisor
                    {
                        dtTravelExp.SetValue("EmpCode", dtTravelExp.Rows.Count - 1, mStrSupervisorCode);
                        dtTravelExp.SetValue("EmpName", dtTravelExp.Rows.Count - 1, mStrSupervisorName);
                        dtTravelExp.SetValue("AcctCode", dtTravelExp.Rows.Count - 1, mStrMinorPurchAcct);
                        dtTravelExp.SetValue("TravPrice", dtTravelExp.Rows.Count - 1, 0);
                        dtTravelExp.SetValue("TravImp", dtTravelExp.Rows.Count - 1, 0);
                        dtTravelExp.SetValue("EmpType", dtTravelExp.Rows.Count - 1, EmployeesTypesEnum.Supervisors.GetDescription());
                        dtTravelExp.SetValue("MovType", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.MinorExpenses.Description);
                        dtTravelExp.SetValue("MovCode", dtTravelExp.Rows.Count - 1, TravelExpMovTypesEnum.MinorExpenses.Value);
                        dtTravelExp.SetValue("TravDays", dtTravelExp.Rows.Count - 1, 1);
                    }
                }

                mtxTravelExp.LoadFromDataSource();
                mtxTravelExp.AutoResizeColumns();

                if (TravelExpMovTypesEnum.IsMinorExpensesType(pEnumMovType)) //supervisor
                {
                    SAPbouiCOM.CommonSetting lObjCmmnSetting = mtxTravelExp.CommonSetting;
                    lObjCmmnSetting.SetCellEditable(dtTravelExp.Rows.Count, 3, true);
                    lObjCmmnSetting.SetCellEditable(dtTravelExp.Rows.Count, 5, true);
                }
            }
            catch (Exception lObjException)
            {
                LogUtility.WriteError(string.Format("[frmTravelExpenses - AddTravelExpenses] Error al agregar la solicitud de consumible: {0}", lObjException.Message));
                throw new Exception(string.Format("Error al agregar la solicitud de consumible {0}", lObjException.Message));
            }
        }
コード例 #2
0
        private void DoPayment()
        {
            try
            {
                if (ValidateEmptyControls())
                {
                    Application.SBO_Application.SetStatusBarMessage("Verificar campos vacíos", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                if (dtTravelExp.Rows.Count <= 0)
                {
                    Application.SBO_Application.SetStatusBarMessage("No puede crear un pago sin líneas", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                if (string.IsNullOrEmpty(mStrExpDayAcct) || string.IsNullOrEmpty(mStrMinorPurchAcct) || string.IsNullOrEmpty(mStrViaticExpAcct) || string.IsNullOrEmpty(mStrViaticPaymAcct))
                {
                    Application.SBO_Application.SetStatusBarMessage("Alguna de las cuentas de configuración no tiene valor, favor de verificar", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                this.UIAPIRawForm.Freeze(true);

                Application.SBO_Application.ActivateMenuItem("2818");

                if (!Application.SBO_Application.Menus.Item("6913").Checked)
                {
                    Application.SBO_Application.ActivateMenuItem("6913");//2050
                }

                SAPbouiCOM.EditText txtDocDate = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("426", -1).Items.Item("10").Specific);
                txtDocDate.Value = DateTime.Now.ToString("yyyyMMdd");

                SAPbouiCOM.OptionBtn optionBtnAccount = ((SAPbouiCOM.OptionBtn)UIApplication.GetApplication().Forms.GetForm("426", -1).Items.Item("58").Specific);
                optionBtnAccount.Selected = true;

                SAPbouiCOM.ComboBox cboPymtType = ((SAPbouiCOM.ComboBox)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_PaymentType").Specific);
                cboPymtType.Select(PaymentsTypesEnum.TravelExpenses.Value, SAPbouiCOM.BoSearchKey.psk_ByValue);

                SAPbouiCOM.EditText txtCodeMov = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_CodeMov").Specific);
                txtCodeMov.Value = txtFolio.Value;

                //SAPbouiCOM.EditText txtCostCenter = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_CostCenter").Specific);
                //txtCostCenter.Value = "MQ_MAQUI";

                SAPbouiCOM.ComboBox cboCostCenter = ((SAPbouiCOM.ComboBox)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_CostCenter").Specific);
                cboCostCenter.Select("MQ_MAQUI", SAPbouiCOM.BoSearchKey.psk_ByValue);

                SAPbouiCOM.ComboBox cboAuxiliarType = ((SAPbouiCOM.ComboBox)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_FZ_AuxiliarType").Specific);
                cboAuxiliarType.Select(((int)AuxiliaryTypeEnum.Employees).ToString(), SAPbouiCOM.BoSearchKey.psk_ByValue);

                SAPbouiCOM.EditText txtAuxiliar = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_FZ_Auxiliar").Specific);
                txtAuxiliar.Value = mStrSupervisorCode;

                SAPbouiCOM.EditText txtFolioOri = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_FolioOri").Specific);
                txtFolioOri.Value = txtRiseFolio.Value;

                SAPbouiCOM.EditText txtObjType = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("-426", -1).Items.Item("U_GLO_ObjType").Specific);
                txtObjType.Value = this.UIAPIRawForm.UniqueID;

                SAPbouiCOM.Button btnBank = ((SAPbouiCOM.Button)UIApplication.GetApplication().Forms.GetForm("426", -1).Items.Item("234000001").Specific);
                btnBank.Item.Click();

                SAPbouiCOM.Folder folderCash = ((SAPbouiCOM.Folder)UIApplication.GetApplication().Forms.GetForm("196", -1).Items.Item("6").Specific);
                folderCash.Item.Click();

                SAPbouiCOM.EditText txtAccount = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("196", -1).Items.Item("32").Specific);
                txtAccount.Value = mStrViaticPaymAcct;

                SAPbouiCOM.EditText txtImport = ((SAPbouiCOM.EditText)UIApplication.GetApplication().Forms.GetForm("196", -1).Items.Item("38").Specific);
                txtImport.Value = txtTotal.Value;

                SAPbouiCOM.Button btnOk = ((SAPbouiCOM.Button)UIApplication.GetApplication().Forms.GetForm("196", -1).Items.Item("1").Specific);
                btnOk.Item.Click();

                SAPbouiCOM.Matrix mtxPayment = ((SAPbouiCOM.Matrix)UIApplication.GetApplication().Forms.GetForm("426", -1).Items.Item("71").Specific);
                for (int i = 0; i < dtTravelExp.Rows.Count; i++)
                {
                    mtxPayment.AddRow();

                    string lStrMovTypeCode  = dtTravelExp.GetValue(9, i).ToString();
                    double lDblLineImport   = double.Parse(dtTravelExp.GetValue(8, i).ToString());
                    string lStrEmployeeType = dtTravelExp.GetValue(10, i).ToString();
                    string lStrEmployeeCode = dtTravelExp.GetValue(5, i).ToString();
                    double lDblDayPrice     = double.Parse(dtTravelExp.GetValue(7, i).ToString());

                    if (lDblDayPrice > 0)
                    {
                        ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("5").Cells.Item(i + 1).Specific).Value = lDblLineImport.ToString();
                        ((SAPbouiCOM.ComboBox)mtxPayment.Columns.Item("U_GLO_TypeViatic").Cells.Item(i + 1).Specific).Select(lStrMovTypeCode.ToString(), SAPbouiCOM.BoSearchKey.psk_ByDescription);
                        ((SAPbouiCOM.ComboBox)mtxPayment.Columns.Item("U_MQ_TypeEmp").Cells.Item(i + 1).Specific).Select(lStrEmployeeType, SAPbouiCOM.BoSearchKey.psk_ByValue);
                        ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("U_MQ_Aux").Cells.Item(i + 1).Specific).Value      = lStrEmployeeCode;
                        ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("U_MQ_DayPrice").Cells.Item(i + 1).Specific).Value = lDblDayPrice.ToString();

                        TravelExpMovTypesEnum lTravExpTypeEnum = TravelExpMovTypesEnum.GetEnum(lStrMovTypeCode);
                        if (TravelExpMovTypesEnum.IsTravelExpensesType(lTravExpTypeEnum))
                        {
                            ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("8").Cells.Item(i + 1).Specific).Value = mStrViaticExpAcct; //cuenta de mayor
                        }
                        else if (TravelExpMovTypesEnum.IsDayExpensesType(lTravExpTypeEnum))
                        {
                            ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("8").Cells.Item(i + 1).Specific).Value = mStrExpDayAcct; //cuenta de mayor
                        }
                        else if (TravelExpMovTypesEnum.IsMinorExpensesType(lTravExpTypeEnum))
                        {
                            ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("8").Cells.Item(i + 1).Specific).Value = mStrMinorPurchAcct; //cuenta de mayor
                        }
                    }
                }

                this.UIAPIRawForm.Close();

                #region Payment

                /*SAPbobsCOM.Payments lObjOutgoingPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPaymentsDrafts);
                 * lObjOutgoingPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_OutgoingPayments;
                 * lObjOutgoingPayment.DocDate = DateTime.Now;
                 * lObjOutgoingPayment.DocType = SAPbobsCOM.BoRcptTypes.rAccount;
                 * lObjOutgoingPayment.CashAccount = mStrViaticPaymAcct;
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value = PaymentsTypesEnum.TravelExpenses.Value;
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_CodeMov").Value = txtFolio.Value; //folio de solicitud de viáticos
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value = "MQ_MAQUI"; //centro de costo
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_FZ_AuxiliarType").Value = ((int)AuxiliaryTypeEnum.Employees).ToString(); //tipo de auxiliar
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_FZ_Auxiliar").Value = mStrSupervisorCode; //auxiliar
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_FolioOri").Value = txtRiseFolio.Value;
                 * lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_ObjType").Value = this.UIAPIRawForm.UniqueID;
                 * lObjOutgoingPayment.CashSum = double.Parse(txtTotal.Value);
                 *
                 * for (int i = 0; i < dtTravelExp.Rows.Count; i++)
                 * {
                 *  string lStrMovTypeCode = dtTravelExp.GetValue(9, i).ToString();
                 *  double lDblLineImport = double.Parse(dtTravelExp.GetValue(8, i).ToString());
                 *  string lStrEmployeeType = dtTravelExp.GetValue(10, i).ToString();
                 *  string lStrEmployeeCode = dtTravelExp.GetValue(5, i).ToString();
                 *  double lDblDayPrice = double.Parse(dtTravelExp.GetValue(7, i).ToString());
                 *
                 *  if (lDblDayPrice > 0)
                 *  {
                 *      lObjOutgoingPayment.AccountPayments.SetCurrentLine(i);
                 *      lObjOutgoingPayment.AccountPayments.SumPaid = lDblLineImport;
                 *      lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_GLO_TypeViatic").Value = lStrMovTypeCode.ToString();
                 *      lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_TypeEmp").Value = lStrEmployeeType;
                 *      lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_Aux").Value = lStrEmployeeCode; //code empleado
                 *      lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_DayPrice").Value = lDblDayPrice;
                 *
                 *      TravelExpMovTypesEnum lTravExpTypeEnum = TravelExpMovTypesEnum.GetEnum(lStrMovTypeCode);
                 *      if (TravelExpMovTypesEnum.IsTravelExpensesType(lTravExpTypeEnum))
                 *      {
                 *          lObjOutgoingPayment.AccountPayments.AccountCode = mStrViaticExpAcct;
                 *      }
                 *      else if (TravelExpMovTypesEnum.IsDayExpensesType(lTravExpTypeEnum))
                 *      {
                 *          lObjOutgoingPayment.AccountPayments.AccountCode = mStrExpDayAcct;
                 *      }
                 *      else if (TravelExpMovTypesEnum.IsMinorExpensesType(lTravExpTypeEnum))
                 *      {
                 *          lObjOutgoingPayment.AccountPayments.AccountCode = mStrMinorPurchAcct;
                 *      }
                 *
                 *      lObjOutgoingPayment.AccountPayments.Add();
                 *  }
                 * }
                 *
                 * if (lObjOutgoingPayment.Add() != 0)
                 * {
                 *  string lStrLastError = DIApplication.Company.GetLastErrorDescription();
                 *  UIApplication.ShowMessageBox(string.Format("Error al generar el pago: {0}", DIApplication.Company.GetLastErrorDescription()));
                 * }
                 * else
                 * {
                 *  int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey());
                 *
                 *  mObjTravelExpensesDTO = mObjMachinerySeviceFactory.GetTravelExpensesService().GetDraftPayment(lIntDocEntry);
                 *
                 *  UIApplication.GetApplication().OpenForm((SAPbouiCOM.BoFormObjectEnum)140, "", lIntDocEntry.ToString());
                 *
                 *  this.UIAPIRawForm.Close();
                 * }*/
                #endregion
            }
            catch (Exception lObjException)
            {
                LogUtility.WriteError(string.Format("[frmTravelExpenses - DoPayment] Error al realizar el pago efectuado: {0}", lObjException.Message));
                Application.SBO_Application.MessageBox(string.Format("Error al realizar el pago efectuado: {0}", lObjException.Message));
            }
            finally
            {
                this.UIAPIRawForm.Freeze(false);
            }
        }