public BVcopyFromStoreResult BVCopyFromStore(BusinessVolumeType bvType, short yearBegin, short yearEnd, long sourceStoreID, long destStoreID) { using (IDbCommand command = CreateCommand()) { command.CommandTimeout = 0; switch (bvType) { case BusinessVolumeType.Actual: command.CommandText = "spBV_ActualAddFromStore"; break; case BusinessVolumeType.Target: command.CommandText = "spBV_TargetAddFromStore"; break; case BusinessVolumeType.CashRegisterReceipt: command.CommandText = "spBV_CRRAddFromStore"; break; default: goto case BusinessVolumeType.Actual; } command.CommandType = CommandType.StoredProcedure; SqlParameter returnParam = new SqlParameter("Return", SqlDbType.Int); returnParam.Direction = ParameterDirection.ReturnValue; command.Parameters.Add(returnParam); SqlParameter yearBeginParam = new SqlParameter("@YearBegin", SqlDbType.SmallInt, 4); yearBeginParam.Direction = ParameterDirection.Input; yearBeginParam.Value = yearBegin; command.Parameters.Add(yearBeginParam); SqlParameter yearEndParam = new SqlParameter("@YearEnd", SqlDbType.SmallInt, 4); yearEndParam.Direction = ParameterDirection.Input; yearEndParam.Value = yearEnd; command.Parameters.Add(yearEndParam); SqlParameter storeIDParam = new SqlParameter("@StoreID", SqlDbType.BigInt, 8); storeIDParam.Direction = ParameterDirection.Input; storeIDParam.Value = sourceStoreID; command.Parameters.Add(storeIDParam); SqlParameter newStoreIDParam = new SqlParameter("@NewStoreID", SqlDbType.BigInt); newStoreIDParam.Direction = ParameterDirection.Input; newStoreIDParam.Value = destStoreID; command.Parameters.Add(newStoreIDParam); command.ExecuteNonQuery(); BVcopyFromStoreResult result = (BVcopyFromStoreResult)returnParam.Value; if (result == BVcopyFromStoreResult.Success) { AddDataIntoCache(bvType, yearBegin, yearEnd, sourceStoreID, destStoreID); } return(result); } }
private void StoreService_BVCopyFromStoreComplete(object sender, OperationCompleteEventArgs e) { if (this.InvokeRequired) { this.Invoke(new OperationCompleteDelegate(StoreService_BVCopyFromStoreComplete), new object[] { sender, e }); } else { if (!e.Success) { if (e.Param is Exception) { error = (Exception)e.Param; DialogResult = DialogResult.Cancel; } else { result = (BVcopyFromStoreResult)e.Param; switch (result) { case BVcopyFromStoreResult.DataExistsInSelectedTimeRange: DialogResult = DialogResult.Cancel; break; case BVcopyFromStoreResult.NoDataCopy: DialogResult = DialogResult.Cancel; break; case BVcopyFromStoreResult.Success: lb_mess.ForeColor = Color.Green; lb_mess.Text = Localizer.GetLocalized("CopyingCompletedSuccessfully"); ProgressBar.Properties.Stopped = true; bt_OK.Enabled = true; break; default: error = new ApplicationException(result.ToString() + "Get Value From invalid result in case"); DialogResult = DialogResult.Cancel; break; } } } else { result = BVcopyFromStoreResult.Success; ProgressBar.Properties.Stopped = true; bt_OK.Enabled = true; lb_mess.ForeColor = Color.Green; lb_mess.Text = Localizer.GetLocalized("CopyingCompletedSuccessfully"); } } }