public void CalculatePlayerFunctionDamage(BaseFunction usedFunction)
 {
     totalDamage = (int)CalculateFunctionIntensity(usedFunction);
     TurnBasedCombatStateMachine.Enemy.RAM -= totalDamage;
     Debug.Log(TurnBasedCombatStateMachine.Enemy.RAM);
     AnalyzeOutcome();
 }
 private float CalculateFunctionIntensity(BaseFunction usedFunction)
 {
     float totalModified = statCalcScript.FunctionIntensityModifications(usedFunction.StrengthModifier, usedFunction.DexterityModifier, usedFunction.IntellectModifier, usedFunction.WeaponModifier);
     if(totalModified > 0){
         return usedFunction.Intensity * (totalModified * statCalcScript.FunctionIntensityRange());
     } else {
         return usedFunction.Intensity * statCalcScript.FunctionIntensityRange();
     }
 }
Exemplo n.º 3
0
 public VBFunction(BaseFunction funcToCopyFrom)
     : base(funcToCopyFrom)
 {
 }
Exemplo n.º 4
0
    public void masterUpstreamPacketAnalyze(DataPacket dp)
    {
        // if(dp.dataLen < 7)
        // {
        //  printf("WRONG MASTER PACKET!\n");
        //  showPacketContent(dp);
        //  return;
        // }
        if (dp.devCode == 0x00)
        {
            switch (dp.data[0]) // cmd
            {
            case 0x00:          // number & addr of devices, data is 0b0000A5B5A4B4...A0B0, Ai = 1, slave connected, Ai = 0, slave not connected, Bi = 1, slave is servo, Bi = 0, slave is motor
            {
                byte[] tmpData = { dp.data[1], dp.data[2] };
                // 0000A5B5A4B4...A0B0 written in bits[16]
                bytes2bits(tmpData);
                // for(int i=0; i<16; ++i)
                //     printf("%d",bits[i]);
                // printf("\n");
                // A[5~0] bits[4,6,8,10,12,14]
                // B[5~0] bits[5,7,9,11,13,15]
                // for(int i=MAX_NUM_OF_THRUSTERS-1, j=0; j<MAX_NUM_OF_THRUSTERS; --i, ++j)
                for (int i = Config.max_num_of_thrusters - 1, j = 0; j < Config.max_num_of_thrusters; --i, ++j)
                {
                    A[i] = m_bits[4 + j * 2];
                    B[i] = m_bits[5 + j * 2];
                    BaseFunction.g_devAddr[i] = A[i];
                }
                // number of devices
                // printf("addr of devices:\n");
                m_numOfDevicesConnected = 0;
                for (int i = 0; i < Config.max_num_of_thrusters; ++i)
                {
                    // printf("%d\t",A[i]);
                    if (A[i] == 1)
                    {
                        m_numOfDevicesConnected++;
                    }
                }
                BaseFunction.g_numOfDevicesConnected = m_numOfDevicesConnected;
                // printf("\n");
                // addr of devices, still use A[i] to identify the addr
                return;

                break;
            }

            case 0x01:     // sendPressure() Q14 format
            {
                // pressure = maxPressure * Q14ToFloat(dp.data[1], dp.data[2]);
                m_pressure = BaseFunction.Q14ToFloat(dp.data[1], dp.data[2]);
                m_depth    = BaseFunction.pressureToDepth(m_pressure);
                BaseFunction.g_pressure = m_pressure;
                BaseFunction.g_depth    = m_depth;
                return;

                break;
            }

            case 0x02:     // sendHygro1() Q14 format
            {
                m_hygro1 = BaseFunction.Q14ToFloat(dp.data[1], dp.data[2]);
                BaseFunction.g_hygro1 = m_hygro1;
                return;
            }

            case 0x03:     // sendHygro2() Q14 format
            {
                m_hygro2 = BaseFunction.Q14ToFloat(dp.data[1], dp.data[2]);
                BaseFunction.g_hygro2 = m_hygro2;
                return;
            }

            case 0x04:     // sendBatteryVolt() Q14 format
            {
                m_batteryVolts = BaseFunction.Q14ToFloat(dp.data[1], dp.data[2]) * Config.max_voltage;
                BaseFunction.g_msBatteryVolts = m_batteryVolts;
                return;
            }

            case 0x05:     // send communication error code, data is 0x00 - 0x06
            {
                int x = (int)dp.data[1];
                BaseFunction.sendErrorCode(communicationErrorCode[x]);
                return;
            }

            case 0x06:
            {
                for (int i = 0; i < Config.max_num_of_thrusters; ++i)
                {
                    m_rpm[i] = BaseFunction.Q14ToFloat(dp.data[2 * i + 1], dp.data[2 * i + 2]) * Config.max_rpm;
                    BaseFunction.g_rpm[i] = (int)m_rpm[i];
                }
                return;
            }

            case 0x07:
            {
                for (int i = 0; i < Config.max_num_of_thrusters; ++i)
                {
                    m_current[i] = BaseFunction.Q14ToFloat(dp.data[2 * i + 1], dp.data[2 * i + 2]) * Config.max_current;
                    BaseFunction.g_current[i] = m_current[i];
                }
                return;
            }

            default:
            {
                Debug.Log("Master upstream packet cmd out of range, invalid packet!\n");
                break;
            }
            }
        }
    }
Exemplo n.º 5
0
        private void btnSave()
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }

                string sErr = "";
                string sSQL = "";

                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    string sInvName = gridView1.GetRowCellDisplayText(i, gridColcInvName).ToString().Trim();
                    if (sInvName == "")
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 存货不正确\n";
                    }

                    string sVenName = gridView1.GetRowCellDisplayText(i, gridColcVenName).ToString().Trim();
                    if (sVenName == "")
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 供应商不正确\n";
                    }

                    decimal d含税单价 = ReturnObjectToDecimal(gridView1.GetRowCellDisplayText(i, gridCol含税单价), 6);
                    if (d含税单价 <= 0)
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 含税单价不正确\n";
                    }

                    if (gridView1.GetRowCellDisplayText(i, gridCol税率).ToString().Trim() == "")
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 税率不正确\n";
                    }
                    decimal d税率 = ReturnObjectToDecimal(gridView1.GetRowCellDisplayText(i, gridCol税率), 6);
                    if (d税率 < 0 || d税率 > 100)
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 税率不正确\n";
                    }
                    sSQL = "select isnull(bProxyForeign,0) as bProxyForeign from @u8.Inventory where cInvCode = 'aaaaaaaaaa'";
                    sSQL = sSQL.Replace("aaaaaaaaaa", gridView1.GetRowCellDisplayText(i, gridColcinvcode).ToString().Trim());
                    int iReturn = BaseFunction.ReturnInt(clsSQLCommond.ExecGetScalar(sSQL));
                    if (iReturn == 0)
                    {
                        sErr = sErr + "行" + (i + 1).ToString() + " 存货【" + gridView1.GetRowCellDisplayText(i, gridColcinvcode).ToString().Trim() + "】" + sInvName + " 不是委外件\n";
                    }
                }

                if (sErr.Length > 0)
                {
                    throw new Exception(sErr);
                }


                ArrayList aList = new ArrayList();
                sSQL = @"
declare @p5 int
set @p5=1000003974
declare @p6 int
set @p6=1000042663
exec @u8.sp_getID N'00',N'200',N'puprice',1,@p5 output,@p6 output
select @p5, @p6
";
                DataTable dt   = clsSQLCommond.ExecQuery(sSQL);
                long      lID  = ReturnObjectToLong(dt.Rows[0][0]);
                long      lIDs = ReturnObjectToLong(dt.Rows[0][1]);

                sSQL = @"
select cNumber as Maxnumber From @u8.VoucherHistory  with (NOLOCK) Where  CardNumber='PU03' and cContent is NULL
";
                dt   = clsSQLCommond.ExecQuery(sSQL);
                long   lCode = ReturnObjectToLong(dt.Rows[0][0]) + 1;
                string sCode = lCode.ToString();
                while (sCode.Length < 10)
                {
                    sCode = "0" + sCode;
                }

                Model.PU_PriceJustMain mod = new OM.Model.PU_PriceJustMain();
                mod.id          = lID;
                mod.ddate       = BaseFunction.ReturnDate(FrameBaseFunction.ClsBaseDataInfo.sLogDate);
                mod.ccode       = sCode;
                mod.cmaker      = FrameBaseFunction.ClsBaseDataInfo.sUserName;
                mod.ivtid       = 31338;
                mod.bTaxCost    = 1;
                mod.iSupplyType = 2;
                mod.cMakeTime   = DateTime.Now;
                mod.iPrintCount = 0;
                //mod.iverifystate = 0;
                mod.cverifier    = FrameBaseFunction.ClsBaseDataInfo.sUserName;
                mod.dverifydate  = BaseFunction.ReturnDate(FrameBaseFunction.ClsBaseDataInfo.sLogDate);
                mod.iverifystate = 2;
                mod.cAuditTime   = mod.cMakeTime;
                mod.cmainmemo    = gridView1.GetRowCellDisplayText(0, gridCol表头备注).ToString().Trim();
                mod.csysbarcode  = @"||putj|" + mod.ccode;

                DAL.PU_PriceJustMain dal = new OM.DAL.PU_PriceJustMain();
                sSQL = dal.Add(mod);
                aList.Add(sSQL);

                int  iRow = 0;
                bool bHas = false;
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    if (!ReturnObjectToBool(gridView1.GetRowCellValue(i, gridCol选择)))
                    {
                        continue;
                    }

                    iRow += 1;
                    lIDs += 1;
                    Model.PU_PriceJustDetail mods = new OM.Model.PU_PriceJustDetail();
                    mods.autoid        = lIDs;
                    mods.id            = lID;
                    mods.operationtype = "0";
                    mods.cvencode      = gridView1.GetRowCellDisplayText(i, gridColcVenCode).ToString().Trim();
                    mods.cinvcode      = gridView1.GetRowCellDisplayText(i, gridColcinvcode).ToString().Trim();

                    mods.bsales       = 0;
                    mods.fminquantity = 0;
                    decimal dTaxRate = ReturnObjectToDecimal(gridView1.GetRowCellDisplayText(i, gridCol税率), 6);
                    if (dTaxRate == 0)
                    {
                        dTaxRate = 16;
                    }
                    mods.iTaxRate      = dTaxRate;
                    mods.iTaxUnitPrice = ReturnObjectToDecimal(gridView1.GetRowCellDisplayText(i, gridCol含税单价), 6);
                    mods.iUnitPrice    = ReturnObjectToDecimal(mods.iTaxUnitPrice / (1 + mods.iTaxRate / 100), 6);
                    mods.cexch_name    = "人民币";
                    mods.ivouchrowno   = iRow;
                    mods.cbodymemo     = gridView1.GetRowCellDisplayText(i, gridCol表体备注).ToString().Trim();
                    mods.cbsysbarcode  = @"||putj|" + mod.ccode + @"|" + mods.ivouchrowno.ToString();


                    mods.dstartdate = BaseFunction.ReturnDate(DateTime.Today.ToString("yyyy-MM-dd"));

                    DAL.PU_PriceJustDetail dals = new OM.DAL.PU_PriceJustDetail();
                    sSQL = dals.Add(mods);
                    aList.Add(sSQL);

                    Model.Ven_Inv_Price modInv = new OM.Model.Ven_Inv_Price();
                    modInv.cVenCode      = mods.cvencode;
                    modInv.cInvCode      = mods.cinvcode;
                    modInv.dEnableDate   = ReturnObjectToDatetime(mods.dstartdate);
                    modInv.cExch_Name    = mods.cexch_name;
                    modInv.bPromotion    = 0;
                    modInv.iSupplyType   = ReturnObjectToInt(mod.iSupplyType);
                    modInv.btaxcost      = 1;
                    modInv.iLowerLimit   = 0;
                    modInv.iUnitPrice    = Convert.ToDecimal(mods.iUnitPrice);
                    modInv.iTaxRate      = Convert.ToDecimal(mods.iTaxRate);
                    modInv.iTaxUnitPrice = Convert.ToDecimal(mods.iTaxUnitPrice);


                    sSQL = "select max(ipriceautoid) from @u8.ven_inv_price";
                    long l = ReturnObjectToLong(clsSQLCommond.ExecGetScalar(sSQL));

                    DAL.Ven_Inv_Price dalInv = new OM.DAL.Ven_Inv_Price();
                    sSQL = dalInv.Exists(modInv);
                    DataTable dtInvPrice = clsSQLCommond.ExecQuery(sSQL);
                    if (ReturnObjectToInt(dtInvPrice.Rows.Count) == 0)
                    {
                        l += 1;
                        modInv.ipriceautoid = l;

                        sSQL = dalInv.Add(modInv);
                        aList.Add(sSQL);
                    }
                    else
                    {
                        modInv.Autoid = ReturnObjectToInt(dtInvPrice.Rows[0]["autoid"]);
                        sSQL          = dalInv.Update(modInv);
                        aList.Add(sSQL);
                    }

                    bHas = true;
                }

                if (!bHas)
                {
                    throw new Exception("没有需要保存的行");
                }

                sSQL = @"
update @u8.VoucherHistory set cNumber='aaaaaa' Where  CardNumber='PU03' and cContent is NULL
";
                sSQL = sSQL.Replace("aaaaaa", lCode.ToString());
                aList.Add(sSQL);


                if (lID > 1000000000)
                {
                    lID = lID - 1000000000;
                }
                if (lIDs > 1000000000)
                {
                    lIDs = lIDs - 1000000000;
                }
                sSQL = "update UFSystem..UA_Identity set iFatherId = " + lID.ToString() + ",iChildId = " + lIDs + " where cAcc_Id = '" + FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName.Substring(7, 3) + "' and cVouchType = 'puprice'";
                aList.Add(sSQL);

                if (aList.Count > 0)
                {
                    clsSQLCommond.ExecSqlTran(aList);
                    MessageBox.Show("保存成功!\n" + mod.ccode);
                    ((DataTable)gridControl1.DataSource).Rows.Clear();
                }
            }
            catch (Exception ee)
            {
                throw new Exception(ee.Message);
            }
        }
Exemplo n.º 6
0
        private void btnDeleteRedVoucher_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Do you want delete this voucher", "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) != DialogResult.Yes)
                {
                    throw new Exception("User cancelled");
                }

                int iRow = gridView1.FocusedRowHandle;
                if (iRow < 0)
                {
                    throw new Exception("Please choose data");
                }

                int iYear   = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiYear));
                int iPeriod = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiPeriod));

                SqlConnection conn = new SqlConnection(Conn);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();

                try
                {
                    string sSQL = "SELECT bflag FROM dbo.GL_mend WHERE iyear = aaaaaa AND iperiod = bbbbbb";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("Failed to obtain module status");
                    }
                    if (BaseFunction.ReturnBool(dt.Rows[0]["bflag"]))
                    {
                        throw new Exception("The current date has been checked out");
                    }

                    sSQL = @"
 update GL_accvouch set iflag = 1
 where iyear = aaaaaaaa and iperiod = bbbbbbbb and csign = 'cccccccc' and ino_id = 'dddddddd'
";
                    sSQL = sSQL.Replace("aaaaaaaa", gridView1.GetRowCellValue(iRow, gridColiYear).ToString());
                    sSQL = sSQL.Replace("bbbbbbbb", gridView1.GetRowCellValue(iRow, gridColiPeriod).ToString());

                    string[] s = gridView1.GetRowCellValue(iRow, gridColRedGLVoucherNO).ToString().Trim().Split('-');
                    sSQL = sSQL.Replace("cccccccc", s[0]);
                    sSQL = sSQL.Replace("dddddddd", s[1]);
                    int iCou = DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    if (iCou > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("Sucess");
                        btnQuery_Click(null, null);
                    }
                    else
                    {
                        throw new Exception("Err:no data");
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "Err";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemplo n.º 7
0
    public DataPacket setAllRPM(int s0, int s1, int s2, int s3, int s4, int s5) // 0x06 + 0xAAAABBBBCCCCDDDDEEEEFFFF, AAAA(slave 0) - FFFF(slave 5), Q14 format
    {
        if (s0 > Config.max_rpm)
        {
            s0 = Config.max_rpm;
        }
        if (s0 < -Config.max_rpm)
        {
            s0 = -Config.max_rpm;
        }
        if (s1 > Config.max_rpm)
        {
            s1 = Config.max_rpm;
        }
        if (s1 < -Config.max_rpm)
        {
            s1 = -Config.max_rpm;
        }
        if (s2 > Config.max_rpm)
        {
            s2 = Config.max_rpm;
        }
        if (s2 < -Config.max_rpm)
        {
            s2 = -Config.max_rpm;
        }
        if (s3 > Config.max_rpm)
        {
            s3 = Config.max_rpm;
        }
        if (s3 < -Config.max_rpm)
        {
            s3 = -Config.max_rpm;
        }
        if (s4 > Config.max_rpm)
        {
            s4 = Config.max_rpm;
        }
        if (s4 < -Config.max_rpm)
        {
            s4 = -Config.max_rpm;
        }
        if (s5 > Config.max_rpm)
        {
            s5 = Config.max_rpm;
        }
        if (s5 < -Config.max_rpm)
        {
            s5 = -Config.max_rpm;
        }
        // cast to uint16_t
        s0 = (ushort)(s0) & 0xffff;
        s1 = (ushort)(s1) & 0xffff;
        s2 = (ushort)(s2) & 0xffff;
        s3 = (ushort)(s3) & 0xffff;
        s4 = (ushort)(s4) & 0xffff;
        s5 = (ushort)(s5) & 0xffff;
        byte[]     tmpData = { 0x06, (byte)(s0 >> 8), (byte)(s0), (byte)(s1 >> 8), (byte)s1, (byte)(s2 >> 8), (byte)s2, (byte)(s3 >> 8), (byte)s3, (byte)(s4 >> 8), (byte)s4, (byte)(s5 >> 8), (byte)s5 };
        DataPacket tmp     = BaseFunction.writePacket(BaseFunction.seq++, 0x00, 0x0d, tmpData);

        return(tmp);
    }
Exemplo n.º 8
0
        private void btnCreateVoucher_Click(object sender, EventArgs e)
        {
            try
            {
                int iRow = gridView1.FocusedRowHandle;
                if (iRow < 0)
                {
                    throw new Exception("Please choose data");
                }

                int iYear   = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiYear));
                int iPeriod = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiPeriod));

                string sVoucher = "";

                int           iCount = 0;
                SqlConnection conn   = new SqlConnection(Conn);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();

                try
                {
                    string sSQL = "SELECT bflag FROM dbo.GL_mend WHERE iyear = aaaaaa AND iperiod = bbbbbb";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("Failed to obtain module status");
                    }
                    if (BaseFunction.ReturnBool(dt.Rows[0]["bflag"]))
                    {
                        throw new Exception("The current date has been checked out");
                    }

                    sSQL = @"
select *
from GL_accvouch gl  inner join _AmountOfExchangeProfitAndLoss b 
	on gl.iyear = b.iYear and gl.iperiod = b.iPeriod and gl.i_id = b.i_id and gl.csign = b.csign
where gl.csign = 'AP' and gl.iyear = aaaaaa and gl.iperiod = bbbbbb and isnull(gl.iflag,0) = 0
";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    dt   = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        throw new Exception("Accounting vouchers already exist");
                    }


                    sSQL = @"
select * from _Code where VouchType = 'Exchange gain or loss'
";
                    dt   = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("Please set aounting subject [_Code.Exchange gain or loss]");
                    }
                    string sKMD = dt.Rows[0]["Debtor"].ToString().Trim();
                    string sKMC = dt.Rows[0]["Creditor"].ToString().Trim();
                    string sZY  = dt.Rows[0]["Remark"].ToString().Trim();
                    if (sKMD == "" || sKMC == "")
                    {
                        throw new Exception("Please set aounting subject [_Code.Exchange gain or loss]");
                    }


                    sSQL = "select isnull(max(ino_id),0)  from GL_accvouch where iyear = aaaaaa AND iperiod = bbbbbb and csign = 'AP'";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    DataTable dtinoid = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    int       ino_id  = BaseFunction.ReturnInt(dtinoid.Rows[0][0]) + 1;

                    sSQL = @"
select sum(AmountOfExchangeProfitAndLoss) as AmountOfExchangeProfitAndLoss ,rd.cVenCode
from _AmountOfExchangeProfitAndLoss a
	left join RdRecord01 rd on a.cCode = rd.cCode
where a.iyear = aaaaaa and a.iperiod = bbbbbb
group by rd.cVenCode
";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    dt   = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("Please do the math first");
                    }

                    decimal dSum = 0;// BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(iRow, gridColAmountOfExchangeProfitAndLoss), 2);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dSum = dSum + BaseFunction.ReturnDecimal(dt.Rows[i]["AmountOfExchangeProfitAndLoss"], 2);
                    }

                    sVoucher = sVoucher + "AP-" + ino_id.ToString().PadLeft(4, '0') + "\n";
                    #region 生成凭证
                    #region 借方
                    Model.GL_accvouch model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.GL_accvouch();
                    model.iperiod    = iPeriod;
                    model.csign      = "AP";
                    model.isignseq   = 2;
                    model.ino_id     = ino_id;
                    model.inid       = 1;
                    model.dbill_date = BaseFunction.ReturnDate(sLogDate);
                    model.idoc       = -1;
                    model.cbill      = sUserName;
                    model.ibook      = 0;
                    model.cdigest    = sZY;
                    model.ccode      = sKMD;
                    //model.cDefine1 = sDocment2;
                    model.md    = BaseFunction.ReturnDecimal(dSum, 2);
                    model.mc    = 0;
                    model.md_f  = 0;
                    model.mc_f  = 0;
                    model.nfrat = 0;
                    model.nd_s  = 0;
                    model.nc_s  = 0;
                    //model.csettle = "";     //结算方式
                    //model.cn_id
                    //model.dt_date =

                    model.ccode_equal = sKMC;;
                    model.bdelete     = false;
                    //model.doutbilldate = model.dbill_date;
                    model.bvouchedit      = true;
                    model.bvouchAddordele = false;
                    model.bvouchmoneyhold = false;
                    model.bvalueedit      = true;
                    model.bcodeedit       = true;
                    model.bPCSedit        = true;
                    model.bDeptedit       = true;
                    model.bItemedit       = true;
                    model.bCusSupInput    = false;
                    model.bFlagOut        = false;
                    model.RowGuid         = Guid.NewGuid().ToString();
                    model.iyear           = iYear;
                    model.iYPeriod        = BaseFunction.ReturnInt(BaseFunction.ReturnDate(iYear.ToString() + "-" + iPeriod.ToString() + "-01").ToString("yyyyMM"));
                    model.tvouchtime      = DateTime.Now;
                    model.ccodeexch_equal = sKMC;

                    UFIDA.U8.UAP.CustomApp.ControlForm.DAL.GL_accvouch dalGL = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.GL_accvouch();
                    sSQL   = dalGL.Add(model);
                    iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    #endregion

                    #region 贷方
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        model            = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.GL_accvouch();
                        model.iperiod    = iPeriod;
                        model.csign      = "AP";
                        model.isignseq   = 2;
                        model.ino_id     = ino_id;
                        model.inid       = 2;
                        model.dbill_date = BaseFunction.ReturnDate(sLogDate);
                        model.idoc       = -1;
                        model.cbill      = sUserName;
                        model.ibook      = 0;
                        model.cdigest    = sZY;
                        model.ccode      = sKMC;
                        //model.cDefine1 = sDocment2;
                        model.md    = 0;
                        model.mc    = BaseFunction.ReturnDecimal(dt.Rows[i]["AmountOfExchangeProfitAndLoss"], 2);
                        model.md_f  = 0;
                        model.mc_f  = 0;
                        model.nfrat = 0;
                        model.nd_s  = 0;
                        model.nc_s  = 0;
                        //model.csettle = "";     //结算方式
                        //model.cn_id
                        //model.dt_date =

                        model.ccode_equal     = sKMD;;
                        model.bdelete         = false;
                        model.doutbilldate    = model.dbill_date;
                        model.bvouchedit      = true;
                        model.bvouchAddordele = false;
                        model.bvouchmoneyhold = false;
                        model.bvalueedit      = true;
                        model.bcodeedit       = true;
                        model.bPCSedit        = true;
                        model.bDeptedit       = true;
                        model.bItemedit       = true;
                        model.bCusSupInput    = false;
                        model.bFlagOut        = false;
                        model.RowGuid         = Guid.NewGuid().ToString();
                        model.iyear           = iYear;
                        model.iYPeriod        = BaseFunction.ReturnInt(BaseFunction.ReturnDate(iYear.ToString() + "-" + iPeriod.ToString() + "-01").ToString("yyyyMM"));
                        model.tvouchtime      = DateTime.Now;
                        model.ccodeexch_equal = sKMD;

                        model.csup_id = dt.Rows[i]["cVenCode"].ToString().Trim();

                        dalGL  = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.GL_accvouch();
                        sSQL   = dalGL.Add(model);
                        iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }
                    #endregion

                    #endregion

                    sSQL = @"
select *
from GL_accvouch
where iyear = {0} and iPeriod = {1} and csign = '{2}' and ino_id = {3}
";
                    sSQL = string.Format(sSQL, model.iyear, model.iperiod, model.csign, model.ino_id);
                    DataTable dtGL = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    long      i_id = BaseFunction.ReturnLong(dtGL.Rows[0]["i_id"]);

                    sSQL = @"
update _AmountOfExchangeProfitAndLoss set csign = 'AP',i_id = 'dddddddd',ino_id = 'eeeeee'
where  iyear = bbbbbbbb and iperiod = cccccccc
";
                    sSQL = sSQL.Replace("bbbbbbbb", model.iyear.ToString());
                    sSQL = sSQL.Replace("cccccccc", model.iperiod.ToString());
                    sSQL = sSQL.Replace("dddddddd", i_id.ToString().Trim());
                    sSQL = sSQL.Replace("eeeeee", model.ino_id.ToString().Trim());
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    tran.Commit();

                    MessageBox.Show("Sucess\n" + sVoucher);
                    btnQuery_Click(null, null);
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "Err";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemplo n.º 9
0
        private void btnCreateRedVoucher_Click(object sender, EventArgs e)
        {
            try
            {
                int iRow = gridView1.FocusedRowHandle;
                if (iRow < 0)
                {
                    throw new Exception("Please choose data");
                }

                int iCou = 0;

                int iYearSource   = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiYear));
                int iPeriodSource = BaseFunction.ReturnInt(gridView1.GetRowCellValue(iRow, gridColiPeriod));

                SqlConnection conn = new SqlConnection(Conn);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();

                try
                {
                    string[] s       = lLoginPeriod.Text.Trim().Split('.');
                    int      iYear   = BaseFunction.ReturnInt(s[0]);
                    int      iPeriod = BaseFunction.ReturnInt(s[1]);

                    string sSQL = @"
SELECT bflag 
FROM dbo.GL_mend 
WHERE iyear = aaaaaa AND iperiod = bbbbbb";
                    sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                    DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("Failed to obtain module status");
                    }
                    if (BaseFunction.ReturnBool(dt.Rows[0]["bflag"]))
                    {
                        throw new Exception("The current date has been checked out");
                    }


                    #region 生成红冲凭证

                    sSQL = @"
select *
from GL_accvouch 
where iyear = aaaaaa and iperiod = bbbbbb  and isnull(iflag,0) = 0
    and ino_id = 'cccccc' and csign = 'dddddd'
    ";
                    sSQL = sSQL.Replace("aaaaaa", iYearSource.ToString());
                    sSQL = sSQL.Replace("bbbbbb", iPeriodSource.ToString());

                    string sGLVoucherNO = gridView1.GetRowCellValue(iRow, gridColGLVoucherNO).ToString().Trim();
                    if (sGLVoucherNO == "")
                    {
                        throw new Exception("Please choose source");
                    }

                    string[] sGlSource = sGLVoucherNO.Split('-');
                    sSQL = sSQL.Replace("cccccc", sGlSource[1]);
                    sSQL = sSQL.Replace("dddddd", sGlSource[0]);

                    dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        MessageBox.Show("No data.Please manually generate the red document");
                    }
                    else
                    {
                        string sGLRedVouch = gridView1.GetRowCellValue(iRow, gridColRedGLVoucherNO).ToString().Trim();
                        if (sGLRedVouch != "")
                        {
                            sGlSource = sGLRedVouch.Split('-');

                            sSQL = @"
select *
from GL_accvouch 
where csign = 'AP' and iyear = aaaaaa and iperiod = bbbbbb and isnull(iflag,0) = 0
    and ino_id = 'cccccc' and csign = 'dddddd'
";
                            sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                            sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                            sSQL = sSQL.Replace("cccccc", sGlSource[1]);
                            sSQL = sSQL.Replace("dddddd", sGlSource[0]);
                            dt   = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                            if (dt != null && dt.Rows.Count > 0)
                            {
                                throw new Exception("Accounting vouchers already exist");
                            }
                        }

                        sSQL = "select isnull(max(ino_id),0) as ino_id from GL_accvouch where iyear = aaaaaa AND iperiod = bbbbbb and csign = 'AP'";
                        sSQL = sSQL.Replace("aaaaaa", iYear.ToString());
                        sSQL = sSQL.Replace("bbbbbb", iPeriod.ToString());
                        DataTable dtinoid = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                        int       ino_id  = BaseFunction.ReturnInt(dtinoid.Rows[0]["ino_id"]);
                        ino_id += 1;
                        string sVoucher = "AP-" + ino_id.ToString().PadLeft(4, '0') + "\n";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            Model.GL_accvouch mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.GL_accvouch();
                            DAL.GL_accvouch   dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.GL_accvouch();

                            mod = dal.DataRowToModel(dt.Rows[i]);

                            mod.ino_id   = ino_id;
                            mod.iyear    = iYear;
                            mod.iperiod  = iPeriod;
                            mod.iYPeriod = BaseFunction.ReturnInt(BaseFunction.ReturnDate(iYearSource.ToString() + "-" + iPeriod.ToString() + "-01").ToString("yyyyMM"));
                            mod.md       = -1 * mod.md;
                            mod.mc       = -1 * mod.mc;
                            mod.md_f     = -1 * mod.md_f;
                            mod.md_f     = -1 * mod.md_f;

                            sSQL  = dal.Add(mod);
                            iCou += DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                        if (iCou > 0)
                        {
                            sSQL = @"
select *
from GL_accvouch
where iyear = {0} and iPeriod = {1} and csign = '{2}' and ino_id = {3}
";
                            sSQL = string.Format(sSQL, iYear.ToString(), iPeriod.ToString(), "AP", ino_id);
                            DataTable dtGL = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                            sSQL = @"
update [dbo].[_AmountOfExchangeProfitAndLoss] set [RedcSign] = 'aaaaaaaa',[Redi_id] = bbbbbbbb,[Redino_id] = 'iiiiiiii'
	,[SourceiYear] =cccccccc ,[SourceiPeriod] = dddddddd,[SourcecSign] = 'eeeeeeee',[Sourceino_id] = ffffffff
where iYear = gggggggg and iPeriod = hhhhhhhh
";
                            sSQL = sSQL.Replace("aaaaaaaa", sGlSource[0]);
                            sSQL = sSQL.Replace("bbbbbbbb", dtGL.Rows[0]["i_id"].ToString());
                            sSQL = sSQL.Replace("cccccccc", iYearSource.ToString());
                            sSQL = sSQL.Replace("dddddddd", iPeriodSource.ToString());
                            sSQL = sSQL.Replace("eeeeeeee", sGlSource[0]);
                            sSQL = sSQL.Replace("ffffffff", sGlSource[1]);
                            sSQL = sSQL.Replace("gggggggg", iYear.ToString());
                            sSQL = sSQL.Replace("hhhhhhhh", iPeriod.ToString());
                            sSQL = sSQL.Replace("iiiiiiii", BaseFunction.ReturnInt(sVoucher.Split('-')[1]).ToString().Trim());
                            int iCount = DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                            if (iCount == 0)
                            {
                                throw new Exception("Please CreateVoucher first");
                            }
                        }
                    }


                    #endregion

                    if (iCou > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("Sucess");
                        btnQuery_Click(null, null);
                    }
                    else
                    {
                        throw new Exception("Err:no data");
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "Err";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemplo n.º 10
0
        private void btnUnAudit_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }

                string        sErr = "";
                int           iCou = 0;
                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    string s会计期间 = lookUpEdit会计期间.EditValue.ToString().Trim();
                    if (s会计期间 == "")
                    {
                        lookUpEdit会计期间.Focus();
                        throw new Exception("会计期间不能为空");
                    }


                    string sSQL = "select count(1) from _辅助费用分配 where 会计期间 = '111111' and isnull(审核人,'') = ''";
                    sSQL = sSQL.Replace("111111", s会计期间);
                    int iCount = BaseFunction.ReturnInt(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                    if (iCount > 0)
                    {
                        throw new Exception("尚未审核");
                    }

                    sSQL   = "select count(1) from _辅助费用分配 where 会计期间 = '111111' and isnull(记账人,'') <> ''";
                    sSQL   = sSQL.Replace("111111", s会计期间);
                    iCount = BaseFunction.ReturnInt(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                    if (iCount > 0)
                    {
                        throw new Exception("已经记账");
                    }

                    sSQL = "update _辅助费用分配 set 审核人 = null ,审核日期 = null where 会计期间 = '111111'";
                    sSQL = sSQL.Replace("111111", s会计期间);
                    iCou = DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    tran.Commit();

                    GetGrid();

                    if (iCou > 0)
                    {
                        MessageBox.Show("弃审成功");
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "删除失败";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemplo n.º 11
0
        private void btn计算_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle += 1;
                    gridView1.FocusedRowHandle -= 1;
                }
                catch {}

                string sErr = "";

                decimal d机修金额 = BaseFunction.ReturnDecimal(txt机修.Text.Trim());
                decimal d仪表金额 = BaseFunction.ReturnDecimal(txt仪表.Text.Trim());
                decimal d环保金额 = BaseFunction.ReturnDecimal(txt环保.Text.Trim());

                decimal d机修总工时 = BaseFunction.ReturnDecimal(gridView1.Columns["机修工时"].SummaryItem.SummaryValue);
                decimal d仪表总工时 = BaseFunction.ReturnDecimal(gridView1.Columns["仪表工时"].SummaryItem.SummaryValue);
                decimal d环保总工时 = BaseFunction.ReturnDecimal(gridView1.Columns["环保工时"].SummaryItem.SummaryValue);

                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    decimal d机修工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol机修工时));
                    if (d机修工时 != 0 && d机修总工时 != 0)
                    {
                        decimal d金额 = d机修工时 / d机修总工时 * d机修金额;
                        gridView1.SetRowCellValue(i, gridCol机修金额, BaseFunction.ReturnDecimal(d金额, 2).ToString().Trim());
                    }
                    else
                    {
                        gridView1.SetRowCellValue(i, gridCol机修金额, DBNull.Value);
                    }

                    decimal d仪表工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol仪表工时));
                    if (d仪表工时 != 0 && d仪表总工时 != 0)
                    {
                        decimal d金额 = d仪表工时 / d仪表总工时 * d仪表金额;
                        gridView1.SetRowCellValue(i, gridCol仪表金额, BaseFunction.ReturnDecimal(d金额, 2).ToString().Trim());
                    }
                    else
                    {
                        gridView1.SetRowCellValue(i, gridCol仪表金额, DBNull.Value);
                    }

                    decimal d环保工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol环保工时));
                    if (d环保工时 != 0 && d环保总工时 != 0)
                    {
                        decimal d金额 = d环保工时 / d环保总工时 * d环保金额;
                        gridView1.SetRowCellValue(i, gridCol环保金额, BaseFunction.ReturnDecimal(d金额, 2).ToString().Trim());
                    }
                    else
                    {
                        gridView1.SetRowCellValue(i, gridCol环保金额, DBNull.Value);
                    }
                }

                if (sErr.Length > 0)
                {
                    throw new Exception(sErr);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Exemplo n.º 12
0
        private void GetGrid()
        {
            try
            {
                SetEnable(true);
                lAudit.Text = "";

                if (lookUpEdit会计期间.EditValue == null || lookUpEdit会计期间.EditValue.ToString().Trim() == "")
                {
                    throw new Exception("请选择会计期间");
                }

                string sSQL = @"
select count(1) from dbo._辅助费用分配 where 会计期间 = '111111'
";
                sSQL = sSQL.Replace("111111", lookUpEdit会计期间.EditValue.ToString());
                int iCou = BaseFunction.ReturnInt(DbHelperSQL.GetSingle(sSQL));
                if (iCou > 0)
                {
                    sSQL = @"
select b.cDepName as 部门,a.*,b.cDepCode
from _辅助费用分配 a right join department b on b.cDepCode = a.部门编码 and a.会计期间 = '111111'
where b.bDepEnd = 1 and b.cDepName  not like '%停用%' and isnull(cDepNameEn,'') like '%FZFY%'
order by a.部门编码
";
                    sSQL = sSQL.Replace("111111", lookUpEdit会计期间.EditValue.ToString());
                    DataTable dt = DbHelperSQL.Query(sSQL);
                    gridControl1.DataSource = dt;

                    txt仪表.Text = gridView1.Columns["仪表金额"].SummaryItem.SummaryValue.ToString().Trim();
                    txt机修.Text = gridView1.Columns["机修金额"].SummaryItem.SummaryValue.ToString().Trim();
                    txt环保.Text = gridView1.Columns["环保金额"].SummaryItem.SummaryValue.ToString().Trim();

                    if (dt.Rows[0]["审核人"].ToString().Trim() != "")
                    {
                        lAudit.Text = "已审核";
                        SetEnable(false);
                    }
                }
                else
                {
                    sSQL = @"
select a.cDepName as 部门,a.cDepCode as 部门编码,a.cDepCode
    ,会计期间,机修工时, 机修金额, 仪表工时, 仪表金额, 环保工时, 环保金额, 合计 
    ,制单人, 制单日期, 审核人, 审核日期, 记账人, 记账日期
from department a left join dbo._辅助费用分配 b on a.cDepCode = b.部门编码 and 会计期间 = '111111'
where isnull(a.bDepEnd,0) = 1 and a.cDepName  not like '%停用%'and isnull(cDepNameEn,'') like '%FZFY%'
order by a.cDepCode
";
                    sSQL = sSQL.Replace("111111", lookUpEdit会计期间.EditValue.ToString());
                    DataTable dt = DbHelperSQL.Query(sSQL);
                    gridControl1.DataSource = dt;

                    txt仪表.Text = null;
                    txt机修.Text = null;
                    txt环保.Text = null;
                }
            }
            catch (Exception ee)
            {
                throw new Exception(ee.Message);
            }
        }
Exemplo n.º 13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }

                if (gridView1.RowCount <= 0)
                {
                    throw new Exception("请设置数据后处理");
                }

                if (BaseFunction.ReturnDecimal(txt仪表.Text.Trim()) != BaseFunction.ReturnDecimal(gridView1.Columns["仪表金额"].SummaryItem.SummaryValue) ||
                    BaseFunction.ReturnDecimal(txt环保.Text.Trim()) != BaseFunction.ReturnDecimal(gridView1.Columns["环保金额"].SummaryItem.SummaryValue) ||
                    BaseFunction.ReturnDecimal(txt机修.Text.Trim()) != BaseFunction.ReturnDecimal(gridView1.Columns["机修金额"].SummaryItem.SummaryValue)
                    )
                {
                    throw new Exception("请重新计算后保存");
                }


                string        sErr = "";
                int           iCou = 0;
                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    string s会计期间 = lookUpEdit会计期间.EditValue.ToString().Trim();
                    if (s会计期间 == "")
                    {
                        lookUpEdit会计期间.Focus();
                        throw new Exception("会计期间不能为空");
                    }

                    string sSQL = "select count(1) from _辅助费用分配 where 会计期间 = '111111' and isnull(审核人,'') <> ''";
                    sSQL = sSQL.Replace("111111", s会计期间);
                    int iCount = BaseFunction.ReturnInt(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                    if (iCount > 0)
                    {
                        throw new Exception("已经审核不能修改");
                    }

                    sSQL = "delete _辅助费用分配 where 会计期间 = '111111'";
                    sSQL = sSQL.Replace("111111", s会计期间);
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        Model._辅助费用分配 model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._辅助费用分配();
                        model.部门编码 = gridView1.GetRowCellValue(i, gridCol部门编码).ToString().Trim();
                        model.仪表工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol仪表工时), 2);
                        model.仪表金额 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol仪表金额), 2);
                        model.机修工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol机修工时), 2);
                        model.机修金额 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol机修金额), 2);
                        model.环保工时 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol环保工时), 2);
                        model.环保金额 = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol环保金额), 2);
                        model.合计   = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridCol合计), 2);
                        model.会计期间 = s会计期间;

                        model.制单人  = sUserName;
                        model.制单日期 = DateTime.Now;

                        DAL._辅助费用分配 dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._辅助费用分配();
                        sSQL = dal.Add(model);

                        iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }

                    tran.Commit();

                    GetGrid();

                    if (iCou > 0)
                    {
                        MessageBox.Show("保存成功");
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "保存失败";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 按钮事情真正执行
        /// </summary>
        /// <param name="ReceiptObject"></param>
        /// <param name="PreExcuteResult"></param>
        /// <returns></returns>
        public string Excute(VoucherProxy ReceiptObject, string PreExcuteResult)
        {
            //Business business = ReceiptObject.Businesses["表体实体ID"]; //取表体实体
            //string str = business.Rows[0].Cells["列名称"].Value; //取表体第一行  某列的值


            ////增加少量数据可以通过修改实体的方式,但是这种方式会有性能问题,每次修改单元格 都会导致界面刷新。
            //Business subEntity = ReceiptObject.Businesses["U8CUSTDEF_0004_E002"];//子表实体 U8CUSTDEF_0004_E002是子表实体编号,可以在UAP中看到
            //for (int i = 0; i < 10; i++)
            //{
            //    string rowKey = subEntity.AddRow(); //rowKey是行 主键值
            //    subEntity.Rows[rowKey].Cells["fQuantity"].Value = "1";
            //    subEntity.Rows[rowKey].Cells["fPrice"].Value = "1";
            //    subEntity.Rows[rowKey].Cells["fAmount"].Value = "1";
            //    subEntity.Rows[rowKey].Cells["cDetailMemo"].Value = "备注" + i.ToString();
            //}

            string sErr = "";

            try
            {
                SqlConnection conn = new SqlConnection(_LoginInfo.UFDataSqlConStr);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();

                try
                {
                    #region 读取数据
                    DataSet   ds    = ReceiptObject.GetData(false, false);
                    DataTable dtHad = ds.Tables[0];

                    DataTable dtDs = ds.Tables[1];

                    if (dtHad.Rows.Count == 0)
                    {
                        string msg = sGetLanguage("没有数据");
                        throw new Exception(msg);
                    }

                    dtHad.Rows[0]["dDate"] = _LoginInfo.LoginDate;

                    DateTime dtmLog = _LoginInfo.LoginDate;
                    int      year   = dtmLog.Year;
                    int      month  = dtmLog.Month;

                    #region 检查汇兑损益基础档案

                    string    sSQL  = @"
select * from TH_ArAp_Set
";
                    DataTable dtSet = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                    //摘要
                    if (dtSet.Rows[0]["cDigest"].ToString().Trim() == "")
                    {
                        string msg = sGetLanguage("请设置摘要");
                        throw new Exception(msg);
                    }
                    //凭证类别
                    if (dtSet.Rows[0]["cSign"].ToString().Trim() == "")
                    {
                        string msg = sGetLanguage("请设置凭证类别");
                        throw new Exception(msg);
                    }

                    //会计科目
                    if (dtSet.Rows[0]["Deptor"].ToString().Trim() == "" || dtSet.Rows[0]["Credit"].ToString().Trim() == "")
                    {
                        string msg = sGetLanguage("请设置会计科目");
                        throw new Exception(msg);
                    }

                    #endregion

                    sSQL = @"
select cCode from TH_AP_HDSY where year(dDate) = {0} and month(dDate) = {1}
";
                    sSQL = string.Format(sSQL, year, month);
                    DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string msg = sGetLanguage("当前期间已有数据");
                        throw new Exception(msg);
                    }

                    DateTime dtmStart = BaseFunction.ReturnDate(year + "-" + month + "-01");
                    DateTime dtmEnd   = dtmStart.AddMonths(1);

                    sSQL = @"
select  cexch_code,cexch_name from dbo.foreigncurrency  where iotherused = -1
";
                    DataTable dtLocal = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dtLocal.Rows.Count == 0)
                    {
                        string msg = sGetLanguage("未设置本币币种");
                        throw new Exception(msg);
                    }
                    string localExName = dtLocal.Rows[0]["cexch_name"].ToString();

                    #endregion

                    Business subEntity = ReceiptObject.Businesses["TH170901_0003_E002"];

                    subEntity.Clear();

                    sSQL = @"
exec [_TH_Get_AP] '{0}'
";
                    sSQL = string.Format(sSQL, dtmLog.ToString("yyyy-MM-dd"));
                    DataTable dtDetails = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];

                    ////大数据刷新显示
                    ReceiptObject.Refresh(ds);

                    for (int i = 0; i < dtDetails.Rows.Count; i++)
                    {
                        // DataRow dr = dtSub.NewRow();
                        // dr["UAPAR001_0001_E001_PK"] = ReceiptObject.CurrentPKValue;  //必须给子表的外键 赋值,子表的外键值=主表的主键值
                        string rowKey = subEntity.AddRow();                                                                                  //rowKey是行 主键值

                        subEntity.Rows[rowKey].Cells["ctypename1"].Value  = sGetLanguage(dtDetails.Rows[i]["ctypename1"].ToString().Trim()); //单据类型
                        subEntity.Rows[rowKey].Cells["cvouchid1"].Value   = dtDetails.Rows[i]["cvouchid1"].ToString().Trim();                //业务单据号
                        subEntity.Rows[rowKey].Cells["dVouchDate1"].Value = dtDetails.Rows[i]["dVouchDate1"].ToString().Trim();              //单据日期
                        subEntity.Rows[rowKey].Cells["cVenCode"].Value    = dtDetails.Rows[i]["cDwCode"].ToString().Trim();                  //供应商编码
                        subEntity.Rows[rowKey].Cells["cVenName"].Value    = dtDetails.Rows[i]["cDwName"].ToString().Trim();                  //供应商名称
                        subEntity.Rows[rowKey].Cells["exchname"].Value    = dtDetails.Rows[i]["exchname"].ToString().Trim();                 //币种
                        subEntity.Rows[rowKey].Cells["iAmount_f1"].Value  = dtDetails.Rows[i]["iAmount_f1"].ToString().Trim();               //本期核销金额
                        subEntity.Rows[rowKey].Cells["HDSY"].Value        = dtDetails.Rows[i]["HDSY"].ToString().Trim();                     //汇兑损益
                        subEntity.Rows[rowKey].Cells["dRate"].Value       = dtDetails.Rows[i]["dRate"].ToString().Trim();                    //汇率
                    }

                    //大数据刷新显示
                    //ReceiptObject.Refresh(ds);

                    tran.Commit();

                    string sMsg = sGetLanguage("读取数据成功");
                    MessageBox.Show(sMsg);

                    return(null);
                }
                catch (Exception ee)
                {
                    tran.Rollback();
                    throw new Exception(ee.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
                return("<result><system result=\"false\" errinfo=\"" + ee.Message + "\"/></result>");   //返回false     不执行Excuted
            }
        }
Exemplo n.º 15
0
 public VBFunction(BaseFunction funcToCopyFrom) : base(funcToCopyFrom)
 {
 }
Exemplo n.º 16
0
 public RelativeRotateAnimation(float diffRadians, float duration,
                                BaseFunction function = null, ContainerType containerType = ContainerType.List, AnimationManager manager = null)
     : base(duration, function, containerType, manager)
 {
     this.m_diffRadians = diffRadians;
 }