예제 #1
0
파일: Work.cs 프로젝트: OlehR/UniCS.TM
        public bool ReturnLastReceipt(int parIdWorkPlace, int parCodePeriod, int parCodeReceipt)
        {
            ParametersCollection varParameters = new ParametersCollection();

            varParameters.Add("parIdWorkplace", parIdWorkPlace, DbType.Int32);
            varParameters.Add("parCodePeriod", parCodePeriod, DbType.Int32);
            varParameters.Add("parCodeReceipt", parCodeReceipt, DbType.Int32);
            varParameters.Add("parIdWorkplaceReturn", GlobalVar.varIdWorkPlace, DbType.Int32);
            varParameters.Add("parCodePeriodReturn", varReceipt.varCodePeriod, DbType.Int32);
            varParameters.Add("parCodeReceiptReturn", varReceipt.varCodeReceipt, DbType.Int32);
            varParameters.Add("parUserCreate", varUser.varCodeUser, DbType.Int32);

            if (GlobalVar.varIdWorkPlace == parIdWorkPlace)
            {
                if (parCodePeriod != varReceipt.varCodePeriod)
                {
                    string varReceiptFile = GlobalVar.varPathDB + parCodePeriod.ToString().Substring(0, 6) + @"\Rc_" + parIdWorkPlace.ToString() + "_" + parCodePeriod.ToString() + ".db";
                    if (File.Exists(varReceiptFile))
                    {
                        varWDB.ExecuteNonQuery("ATTACH '" + varReceiptFile + "' AS rrc");
                        bool varRez = varWDB.CopyWaresReturnReceipt(varParameters);
                        varWDB.ExecuteNonQuery("DETACH DATABASE rrc");
                        return(varRez);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(varWDB.CopyWaresReturnReceipt(varParameters));
                }
            }
            else              // Якщо інше робоче місце
            {
                //return false;
            }
            return(false);
        }