code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package org.anddev.andengine.audio.music; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.media.MediaPlayer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:05:49 - 13.06.2010 */ public class MusicFactory { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private static String sAssetBasePath = ""; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== /** * @param pAssetBasePath must end with '<code>/</code>' or have <code>.length() == 0</code>. */ public static void setAssetBasePath(final String pAssetBasePath) { if(pAssetBasePath.endsWith("/") || pAssetBasePath.length() == 0) { MusicFactory.sAssetBasePath = pAssetBasePath; } else { throw new IllegalStateException("pAssetBasePath must end with '/' or be lenght zero."); } } public static void reset() { MusicFactory.setAssetBasePath(""); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static Music createMusicFromFile(final MusicManager pMusicManager, final File pFile) throws IOException { final MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource(new FileInputStream(pFile).getFD()); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } public static Music createMusicFromAsset(final MusicManager pMusicManager, final Context pContext, final String pAssetPath) throws IOException { final MediaPlayer mediaPlayer = new MediaPlayer(); final AssetFileDescriptor assetFileDescritor = pContext.getAssets().openFd(MusicFactory.sAssetBasePath + pAssetPath); mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } public static Music createMusicFromResource(final MusicManager pMusicManager, final Context pContext, final int pMusicResID) throws IOException { final MediaPlayer mediaPlayer = MediaPlayer.create(pContext, pMusicResID); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/audio/music/MusicFactory.java
Java
lgpl
3,383
package org.anddev.andengine.audio.music; import org.anddev.andengine.audio.BaseAudioManager; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:01:23 - 13.06.2010 */ public class MusicManager extends BaseAudioManager<Music> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MusicManager() { } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/audio/music/MusicManager.java
Java
lgpl
1,408
package org.anddev.andengine.audio.music; import org.anddev.andengine.audio.BaseAudioEntity; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:53:12 - 13.06.2010 */ public class Music extends BaseAudioEntity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final MediaPlayer mMediaPlayer; // =========================================================== // Constructors // =========================================================== Music(final MusicManager pMusicManager, final MediaPlayer pMediaPlayer) { super(pMusicManager); this.mMediaPlayer = pMediaPlayer; } // =========================================================== // Getter & Setter // =========================================================== public boolean isPlaying() { return this.mMediaPlayer.isPlaying(); } public MediaPlayer getMediaPlayer() { return this.mMediaPlayer; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected MusicManager getAudioManager() { return (MusicManager)super.getAudioManager(); } @Override public void play() { this.mMediaPlayer.start(); } @Override public void stop() { this.mMediaPlayer.stop(); } @Override public void resume() { this.mMediaPlayer.start(); } @Override public void pause() { this.mMediaPlayer.pause(); } @Override public void release() { this.mMediaPlayer.release(); } @Override public void setLooping(final boolean pLooping) { this.mMediaPlayer.setLooping(pLooping); } @Override public void setVolume(final float pLeftVolume, final float pRightVolume) { super.setVolume(pLeftVolume, pRightVolume); final float masterVolume = this.getAudioManager().getMasterVolume(); final float actualLeftVolume = pLeftVolume * masterVolume; final float actualRightVolume = pRightVolume * masterVolume; this.mMediaPlayer.setVolume(actualLeftVolume, actualRightVolume); } @Override public void onMasterVolumeChanged(final float pMasterVolume) { this.setVolume(this.mLeftVolume, this.mRightVolume); } // =========================================================== // Methods // =========================================================== public void seekTo(final int pMilliseconds) { this.mMediaPlayer.seekTo(pMilliseconds); } public void setOnCompletionListener(final OnCompletionListener pOnCompletionListener) { this.mMediaPlayer.setOnCompletionListener(pOnCompletionListener); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/audio/music/Music.java
Java
lgpl
3,193
package org.anddev.andengine.audio; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:02:06 - 13.06.2010 */ public interface IAudioManager<T extends IAudioEntity> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public float getMasterVolume(); public void setMasterVolume(final float pMasterVolume); public void add(final T pAudioEntity); public void releaseAll(); }
07734dan-learnmore
src/org/anddev/andengine/audio/IAudioManager.java
Java
lgpl
692
package org.anddev.andengine.audio; import java.util.ArrayList; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:07:02 - 13.06.2010 */ public abstract class BaseAudioManager<T extends IAudioEntity> implements IAudioManager<T> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected final ArrayList<T> mAudioEntities = new ArrayList<T>(); protected float mMasterVolume = 1.0f; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public float getMasterVolume() { return this.mMasterVolume; } @Override public void setMasterVolume(final float pMasterVolume) { this.mMasterVolume = pMasterVolume; final ArrayList<T> audioEntities = this.mAudioEntities; for(int i = audioEntities.size() - 1; i >= 0; i--) { final T audioEntity = audioEntities.get(i); audioEntity.onMasterVolumeChanged(pMasterVolume); } } @Override public void add(final T pAudioEntity) { this.mAudioEntities.add(pAudioEntity); } @Override public void releaseAll() { final ArrayList<T> audioEntities = this.mAudioEntities; for(int i = audioEntities.size() - 1; i >= 0; i--) { final T audioEntity = audioEntities.get(i); audioEntity.stop(); audioEntity.release(); } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/audio/BaseAudioManager.java
Java
lgpl
2,284
package org.anddev.andengine.audio; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:53:29 - 13.06.2010 */ public interface IAudioEntity { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void play(); public void pause(); public void resume(); public void stop(); public float getVolume(); public void setVolume(final float pVolume); public float getLeftVolume(); public float getRightVolume(); public void setVolume(final float pLeftVolume, final float pRightVolume); public void onMasterVolumeChanged(final float pMasterVolume); public void setLooping(final boolean pLooping); public void release(); }
07734dan-learnmore
src/org/anddev/andengine/audio/IAudioEntity.java
Java
lgpl
957
package org.anddev.andengine.ui.activity; import org.anddev.andengine.audio.music.MusicManager; import org.anddev.andengine.audio.sound.SoundManager; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.engine.options.EngineOptions; import org.anddev.andengine.engine.options.WakeLockOptions; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.opengl.font.FontManager; import org.anddev.andengine.opengl.texture.TextureManager; import org.anddev.andengine.opengl.view.RenderSurfaceView; import org.anddev.andengine.sensor.accelerometer.AccelerometerSensorOptions; import org.anddev.andengine.sensor.accelerometer.IAccelerometerListener; import org.anddev.andengine.sensor.location.ILocationListener; import org.anddev.andengine.sensor.location.LocationSensorOptions; import org.anddev.andengine.sensor.orientation.IOrientationListener; import org.anddev.andengine.sensor.orientation.OrientationSensorOptions; import org.anddev.andengine.ui.IGameInterface; import org.anddev.andengine.util.ActivityUtils; import org.anddev.andengine.util.Debug; import android.content.Context; import android.content.pm.ActivityInfo; import android.media.AudioManager; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.view.Gravity; import android.widget.FrameLayout.LayoutParams; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:27:06 - 08.03.2010 */ public abstract class BaseGameActivity extends BaseActivity implements IGameInterface { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected Engine mEngine; private WakeLock mWakeLock; protected RenderSurfaceView mRenderSurfaceView; protected boolean mHasWindowFocused; private boolean mPaused; private boolean mGameLoaded; // =========================================================== // Constructors // =========================================================== @Override protected void onCreate(final Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); this.mPaused = true; this.mEngine = this.onLoadEngine(); this.applyEngineOptions(this.mEngine.getEngineOptions()); this.onSetContentView(); } @Override protected void onResume() { super.onResume(); if(this.mPaused && this.mHasWindowFocused) { this.doResume(); } } @Override public void onWindowFocusChanged(final boolean pHasWindowFocus) { super.onWindowFocusChanged(pHasWindowFocus); if(pHasWindowFocus) { if(this.mPaused) { this.doResume(); } this.mHasWindowFocused = true; } else { if(!this.mPaused) { this.doPause(); } this.mHasWindowFocused = false; } } @Override protected void onPause() { super.onPause(); if(!this.mPaused) { this.doPause(); } } @Override protected void onDestroy() { super.onDestroy(); this.mEngine.interruptUpdateThread(); this.onUnloadResources(); } @Override public void onUnloadResources() { if(this.mEngine.getEngineOptions().needsMusic()) { this.getMusicManager().releaseAll(); } if(this.mEngine.getEngineOptions().needsSound()) { this.getSoundManager().releaseAll(); } } // =========================================================== // Getter & Setter // =========================================================== public Engine getEngine() { return this.mEngine; } public TextureManager getTextureManager() { return this.mEngine.getTextureManager(); } public FontManager getFontManager() { return this.mEngine.getFontManager(); } public SoundManager getSoundManager() { return this.mEngine.getSoundManager(); } public MusicManager getMusicManager() { return this.mEngine.getMusicManager(); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onResumeGame() { } @Override public void onPauseGame() { } // =========================================================== // Methods // =========================================================== private void doResume() { if(!this.mGameLoaded) { this.onLoadResources(); final Scene scene = this.onLoadScene(); this.mEngine.onLoadComplete(scene); this.onLoadComplete(); this.mGameLoaded = true; } this.mPaused = false; this.acquireWakeLock(this.mEngine.getEngineOptions().getWakeLockOptions()); this.mEngine.onResume(); this.mRenderSurfaceView.onResume(); this.mEngine.start(); this.onResumeGame(); } private void doPause() { this.mPaused = true; this.releaseWakeLock(); this.mEngine.onPause(); this.mEngine.stop(); this.mRenderSurfaceView.onPause(); this.onPauseGame(); } public void runOnUpdateThread(final Runnable pRunnable) { this.mEngine.runOnUpdateThread(pRunnable); } protected void onSetContentView() { this.mRenderSurfaceView = new RenderSurfaceView(this); this.mRenderSurfaceView.setEGLConfigChooser(false); this.mRenderSurfaceView.setRenderer(this.mEngine); this.setContentView(this.mRenderSurfaceView, this.createSurfaceViewLayoutParams()); } private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) { if(pWakeLockOptions == WakeLockOptions.SCREEN_ON) { ActivityUtils.keepScreenOn(this); } else { final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, "AndEngine"); try { this.mWakeLock.acquire(); } catch (final SecurityException e) { Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", e); } } } private void releaseWakeLock() { if(this.mWakeLock != null && this.mWakeLock.isHeld()) { this.mWakeLock.release(); } } private void applyEngineOptions(final EngineOptions pEngineOptions) { if(pEngineOptions.isFullscreen()) { ActivityUtils.requestFullscreen(this); } if(pEngineOptions.needsMusic() || pEngineOptions.needsSound()) { this.setVolumeControlStream(AudioManager.STREAM_MUSIC); } switch(pEngineOptions.getScreenOrientation()) { case LANDSCAPE: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case PORTRAIT: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; } } protected LayoutParams createSurfaceViewLayoutParams() { final LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; } protected void enableVibrator() { this.mEngine.enableVibrator(this); } /** * @see {@link Engine#enableLocationSensor(Context, ILocationListener, LocationSensorOptions)} */ protected void enableLocationSensor(final ILocationListener pLocationListener, final LocationSensorOptions pLocationSensorOptions) { this.mEngine.enableLocationSensor(this, pLocationListener, pLocationSensorOptions); } /** * @see {@link Engine#disableLocationSensor(Context)} */ protected void disableLocationSensor() { this.mEngine.disableLocationSensor(this); } /** * @see {@link Engine#enableAccelerometerSensor(Context, IAccelerometerListener)} */ protected boolean enableAccelerometerSensor(final IAccelerometerListener pAccelerometerListener) { return this.mEngine.enableAccelerometerSensor(this, pAccelerometerListener); } /** * @see {@link Engine#enableAccelerometerSensor(Context, IAccelerometerListener, AccelerometerSensorOptions)} */ protected boolean enableAccelerometerSensor(final IAccelerometerListener pAccelerometerListener, final AccelerometerSensorOptions pAccelerometerSensorOptions) { return this.mEngine.enableAccelerometerSensor(this, pAccelerometerListener, pAccelerometerSensorOptions); } /** * @see {@link Engine#disableAccelerometerSensor(Context)} */ protected boolean disableAccelerometerSensor() { return this.mEngine.disableAccelerometerSensor(this); } /** * @see {@link Engine#enableOrientationSensor(Context, IOrientationListener)} */ protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener) { return this.mEngine.enableOrientationSensor(this, pOrientationListener); } /** * @see {@link Engine#enableOrientationSensor(Context, IOrientationListener, OrientationSensorOptions)} */ protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener, final OrientationSensorOptions pLocationSensorOptions) { return this.mEngine.enableOrientationSensor(this, pOrientationListener, pLocationSensorOptions); } /** * @see {@link Engine#disableOrientationSensor(Context)} */ protected boolean disableOrientationSensor() { return this.mEngine.disableOrientationSensor(this); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/ui/activity/BaseGameActivity.java
Java
lgpl
9,629
package org.anddev.andengine.ui.activity; import org.anddev.andengine.opengl.view.RenderSurfaceView; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:18:50 - 06.10.2010 */ public abstract class LayoutGameActivity extends BaseGameActivity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract int getLayoutID(); protected abstract int getRenderSurfaceViewID(); @Override protected void onSetContentView() { super.setContentView(this.getLayoutID()); this.mRenderSurfaceView = (RenderSurfaceView) this.findViewById(this.getRenderSurfaceViewID()); this.mRenderSurfaceView.setEGLConfigChooser(false); this.mRenderSurfaceView.setRenderer(this.mEngine); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/ui/activity/LayoutGameActivity.java
Java
lgpl
1,795
package org.anddev.andengine.ui.activity; import java.util.concurrent.Callable; import org.anddev.andengine.util.ActivityUtils; import org.anddev.andengine.util.AsyncCallable; import org.anddev.andengine.util.Callback; import org.anddev.andengine.util.progress.ProgressCallable; import android.app.Activity; import android.app.ProgressDialog; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:35:28 - 29.08.2009 */ public abstract class BaseActivity extends Activity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== /** * Performs a task in the background, showing a {@link ProgressDialog}, * while the {@link Callable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pCallable * @param pCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final Callable<T> pCallable, final Callback<T> pCallback) { this.doAsync(pTitleResID, pMessageResID, pCallable, pCallback, null); } /** * Performs a task in the background, showing a indeterminate {@link ProgressDialog}, * while the {@link Callable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final Callable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doAsync(this, pTitleResID, pMessageResID, pCallable, pCallback, pExceptionCallback); } /** * Performs a task in the background, showing a {@link ProgressDialog} with an ProgressBar, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback */ protected <T> void doProgressAsync(final int pTitleResID, final ProgressCallable<T> pCallable, final Callback<T> pCallback) { this.doProgressAsync(pTitleResID, pCallable, pCallback, null); } /** * Performs a task in the background, showing a {@link ProgressDialog} with a ProgressBar, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doProgressAsync(final int pTitleResID, final ProgressCallable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doProgressAsync(this, pTitleResID, pCallable, pCallback, pExceptionCallback); } /** * Performs a task in the background, showing an indeterminate {@link ProgressDialog}, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final AsyncCallable<T> pAsyncCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doAsync(this, pTitleResID, pMessageResID, pAsyncCallable, pCallback, pExceptionCallback); } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static class CancelledException extends Exception { private static final long serialVersionUID = -78123211381435596L; } }
07734dan-learnmore
src/org/anddev/andengine/ui/activity/BaseActivity.java
Java
lgpl
4,667
package org.anddev.andengine.ui.activity; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.timer.ITimerCallback; import org.anddev.andengine.engine.handler.timer.TimerHandler; import org.anddev.andengine.engine.options.EngineOptions; import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation; import org.anddev.andengine.engine.options.resolutionpolicy.IResolutionPolicy; import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.entity.scene.SplashScene; import org.anddev.andengine.opengl.texture.TextureOptions; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasFactory; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.anddev.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; import org.anddev.andengine.opengl.texture.bitmap.BitmapTexture.BitmapTextureFormat; import org.anddev.andengine.opengl.texture.region.TextureRegion; import android.app.Activity; import android.content.Intent; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 08:25:31 - 03.05.2010 */ public abstract class BaseSplashActivity extends BaseGameActivity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private Camera mCamera; private IBitmapTextureAtlasSource mSplashTextureAtlasSource; private TextureRegion mLoadingScreenTextureRegion; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract ScreenOrientation getScreenOrientation(); protected abstract IBitmapTextureAtlasSource onGetSplashTextureAtlasSource(); protected abstract float getSplashDuration(); protected abstract Class<? extends Activity> getFollowUpActivity(); protected float getSplashScaleFrom() { return 1f; } protected float getSplashScaleTo() { return 1f; } @Override public void onLoadComplete() { } @Override public Engine onLoadEngine() { this.mSplashTextureAtlasSource = this.onGetSplashTextureAtlasSource(); final int width = this.mSplashTextureAtlasSource.getWidth(); final int height = this.mSplashTextureAtlasSource.getHeight(); this.mCamera = this.getSplashCamera(width, height); return new Engine(new EngineOptions(true, this.getScreenOrientation(), this.getSplashResolutionPolicy(width, height), this.mCamera)); } @Override public void onLoadResources() { final BitmapTextureAtlas loadingScreenBitmapTextureAtlas = BitmapTextureAtlasFactory.createForTextureAtlasSourceSize(BitmapTextureFormat.RGBA_8888, this.mSplashTextureAtlasSource, TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.mLoadingScreenTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(loadingScreenBitmapTextureAtlas, this.mSplashTextureAtlasSource, 0, 0); this.getEngine().getTextureManager().loadTexture(loadingScreenBitmapTextureAtlas); } @Override public Scene onLoadScene() { final float splashDuration = this.getSplashDuration(); final SplashScene splashScene = new SplashScene(this.mCamera, this.mLoadingScreenTextureRegion, splashDuration, this.getSplashScaleFrom(), this.getSplashScaleTo()); splashScene.registerUpdateHandler(new TimerHandler(splashDuration, new ITimerCallback() { @Override public void onTimePassed(final TimerHandler pTimerHandler) { BaseSplashActivity.this.startActivity(new Intent(BaseSplashActivity.this, BaseSplashActivity.this.getFollowUpActivity())); BaseSplashActivity.this.finish(); } })); return splashScene; } // =========================================================== // Methods // =========================================================== protected Camera getSplashCamera(final int pSplashwidth, final int pSplashHeight) { return new Camera(0, 0, pSplashwidth, pSplashHeight); } protected IResolutionPolicy getSplashResolutionPolicy(final int pSplashwidth, final int pSplashHeight) { return new RatioResolutionPolicy(pSplashwidth, pSplashHeight); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/ui/activity/BaseSplashActivity.java
Java
lgpl
5,135
package org.anddev.andengine.ui; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.entity.scene.Scene; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:03:08 - 14.03.2010 */ public interface IGameInterface { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public Engine onLoadEngine(); public void onLoadResources(); public void onUnloadResources(); public Scene onLoadScene(); public void onLoadComplete(); public void onPauseGame(); public void onResumeGame(); }
07734dan-learnmore
src/org/anddev/andengine/ui/IGameInterface.java
Java
lgpl
819
package org.anddev.andengine.ui.dialog; import org.anddev.andengine.util.Callback; import android.content.Context; import android.content.DialogInterface.OnCancelListener; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:46:00 - 14.12.2009 */ public class StringInputDialogBuilder extends GenericInputDialogBuilder<String> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public StringInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final Callback<String> pSuccessCallback, final OnCancelListener pOnCancelListener) { super(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, pSuccessCallback, pOnCancelListener); } public StringInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final String pDefaultText, final Callback<String> pSuccessCallback, final OnCancelListener pOnCancelListener) { super(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, pDefaultText, pSuccessCallback, pOnCancelListener); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected String generateResult(final String pInput) { return pInput; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/ui/dialog/StringInputDialogBuilder.java
Java
lgpl
2,316
package org.anddev.andengine.ui.dialog; import org.anddev.andengine.util.Callback; import org.anddev.andengine.util.Debug; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.widget.EditText; import android.widget.Toast; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:35:55 - 14.12.2009 */ public abstract class GenericInputDialogBuilder<T> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected final Callback<T> mSuccessCallback; protected final OnCancelListener mOnCancelListener; protected final int mTitleResID; protected final int mMessageResID; protected final int mIconResID; protected final Context mContext; private final int mErrorResID; private final String mDefaultText; // =========================================================== // Constructors // =========================================================== public GenericInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final Callback<T> pSuccessCallback, final OnCancelListener pOnCancelListener){ this(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, "", pSuccessCallback, pOnCancelListener); } public GenericInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final String pDefaultText, final Callback<T> pSuccessCallback, final OnCancelListener pOnCancelListener){ this.mContext = pContext; this.mTitleResID = pTitleResID; this.mMessageResID = pMessageResID; this.mErrorResID = pErrorResID; this.mIconResID = pIconResID; this.mDefaultText = pDefaultText; this.mSuccessCallback = pSuccessCallback; this.mOnCancelListener = pOnCancelListener; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract T generateResult(final String pInput); // =========================================================== // Methods // =========================================================== public Dialog create() { final EditText etInput = new EditText(this.mContext); etInput.setText(this.mDefaultText); final AlertDialog.Builder ab = new AlertDialog.Builder(this.mContext); if(this.mTitleResID != 0) { ab.setTitle(this.mTitleResID); } if(this.mMessageResID != 0) { ab.setMessage(this.mMessageResID); } if(this.mIconResID != 0) { ab.setIcon(this.mIconResID); } this.setView(ab, etInput); ab.setOnCancelListener(this.mOnCancelListener) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface pDialog, final int pWhich) { final T result; try{ result = GenericInputDialogBuilder.this.generateResult(etInput.getText().toString()); } catch (final IllegalArgumentException e) { Debug.e("Error in GenericInputDialogBuilder.generateResult()", e); Toast.makeText(GenericInputDialogBuilder.this.mContext, GenericInputDialogBuilder.this.mErrorResID, Toast.LENGTH_SHORT).show(); return; } GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result); pDialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(final DialogInterface pDialog, final int pWhich) { GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog); pDialog.dismiss(); } }); return ab.create(); } protected void setView(final AlertDialog.Builder pBuilder, final EditText pInputEditText) { pBuilder.setView(pInputEditText); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
07734dan-learnmore
src/org/anddev/andengine/ui/dialog/GenericInputDialogBuilder.java
Java
lgpl
4,605
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class NguyenVatLieuBUS { public static List<NGUYENVATLIEU> layDSNVL() { return NguyenVatLieuDAO.layDSNVL(); } public static NGUYENVATLIEU layNVL(int maNVL) { return NguyenVatLieuDAO.layNVL(maNVL); } public static int layMaNVLLonNhat() { return NguyenVatLieuDAO.layMaNVLLonNhat(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/NguyenVatLieuBUS.cs
C#
asf20
565
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; using System.Data; namespace BUS { public static class MonAnBUS { public static bool themMonAn(MONAN monan) { return MonAnDAO.themMonAn(monan); } public static bool capNhatMonAn(MONAN monan) { return MonAnDAO.capNhatMonAn(monan); } public static int layMaMonAnLonNhat() { return MonAnDAO.layMaMonAnLonNhat(); } public static List<MONAN> layDSMA() { return MonAnDAO.layDSMA(); } public static DataTable layNVLMonAnDauTien() { DataTable dt = new DataTable(); MONAN monan = MonAnDAO.layMonAnDauTien(); DataColumn maNVL = new DataColumn("Mã nguyên vật liệu"); dt.Columns.Add(maNVL); dt.Columns[0].ReadOnly = true; DataColumn tenNVL = new DataColumn("Tên nguyên vật liệu"); dt.Columns.Add(tenNVL); dt.Columns[1].ReadOnly = true; DataColumn soLuongNVL = new DataColumn("Số lượng cần thiết"); dt.Columns.Add(soLuongNVL); dt.Columns[2].ReadOnly = true; foreach (DS_NVL_MONAN nvl_ma in monan.DS_NVL_MONAN) { DataRow row = dt.NewRow(); row[0] = nvl_ma.MaNVL; row[1] = NguyenVatLieuBUS.layNVL(nvl_ma.MaNVL).TenNVL; row[2] = nvl_ma.SoLuongNVLCan; dt.Rows.Add(row); } return dt; } public static DataTable layNVLMonAn(int maMA) { DataTable dt = new DataTable(); MONAN monan = MonAnDAO.layMonAn(maMA); DataColumn maNVL = new DataColumn("MaNVL"); dt.Columns.Add(maNVL); DataColumn tenNVL = new DataColumn("TenNVL"); dt.Columns.Add(tenNVL); DataColumn soLuongNVL = new DataColumn("SoLuongNVL"); dt.Columns.Add(soLuongNVL); foreach (DS_NVL_MONAN nvl_ma in monan.DS_NVL_MONAN) { DataRow row = dt.NewRow(); row[0] = nvl_ma.MaNVL; row[1] = nvl_ma.NGUYENVATLIEU.TenNVL; row[2] = nvl_ma.SoLuongNVLCan; dt.Rows.Add(row); } return dt; } public static MONAN layMonAn(int maMA) { return MonAnDAO.layMonAn(maMA); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/MonAnBUS.cs
C#
asf20
2,652
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class KhachHangBUS { public static List<KHACHHANG> layDSKH() { return KhachHangDAO.layDSKH(); } public static KHACHHANG layKH(int maKH) { return KhachHangDAO.layKH(maKH); } public static void ThemKhachHang(KHACHHANG kh) { KhachHangDAO.ThemKhachHang(kh); } public static void CapNhatKhachHang(KHACHHANG kh) { KhachHangDAO.CapNhatKhachHang(kh); } public static bool capNhatDiemTichLuy(KHACHHANG kh) { return KhachHangDAO.capNhatDiemTichLuy(kh); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/KhachHangBUS.cs
C#
asf20
812
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class HoaDon_DiemTichLuyBUS { public static int layDiemTichLuy(decimal tongTienHD) { return HoaDon_DiemTichLuyDAO.layDiemTichLuy(tongTienHD); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/HoaDon_DiemTichLuyBUS.cs
C#
asf20
343
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public class NhanVienBUS { NhanVienDAO NhanVienDAO = new NhanVienDAO(); public bool dangNhap(int maNV, string matKhau) { return NhanVienDAO.dangNhap(maNV, matKhau); } public NHANVIEN layNV(int maNV) { return NhanVienDAO.layNV(maNV); } public List<NHANVIEN> LayDS_NV() { return NhanVienDAO.LayDS_NV(); } public List<LOAINHANVIEN> LayDS_Loai() { return NhanVienDAO.LayDS_Loai(); } public void CapNhat_NV(NHANVIEN nv) { NhanVienDAO.CapNhat_NV(nv); } public void Them_NV(NHANVIEN nv) { NhanVienDAO.Them_NV(nv); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/NhanVienBUS.cs
C#
asf20
910
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class HoaDonSPBUS { public static List<HOADON_SP> layDSHDSP() { return HoaDonSPDAO.layDSHDSP(); } public static int layMaHDLonNhat() { return HoaDonSPDAO.layMaHDLonNhat(); } public static bool themHoaDonSP(HOADON_SP hoaDonSP) { return HoaDonSPDAO.themHoaDonSP(hoaDonSP); } public static bool capNhatHoaDon(HOADON_SP hoaDon) { return HoaDonSPDAO.capNhatHoaDon(hoaDon); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/HoaDonSPBUS.cs
C#
asf20
695
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class SanPhamBUS { public static List<SANPHAM> layDSSP() { return SanPhamDAO.layDSSP(); } public static SANPHAM laySP(int maSP) { return SanPhamDAO.laySP(maSP); } public static void ThemSanPham(SANPHAM sanpham) { SanPhamDAO.ThemSanPham(sanpham); } public static void CapNhatSanPham(SANPHAM sanpham) { SanPhamDAO.CapNhatSanPham(sanpham); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/SanPhamBUS.cs
C#
asf20
662
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public class LapThucDonBus { LapThucDonDao daoTD = new LapThucDonDao(); public List<MonAnPublic> LayDS_MonAn() { return daoTD.LayDS_MonAn(); } public bool ThemThucDon(THUCDON_NGAY ThucDon) { return daoTD.ThemThucDon(ThucDon); } public void CapNhatChiTiet(CHITIET_THUCDON ThucDon) { daoTD.CapNhatChiTiet(ThucDon); } public List<ThucDonPublic> getWeek() { return daoTD.getWeek(); } public List<ThucDonPublic> NgayTrongTuan(string tuan) { return daoTD.NgayTrongTuan(tuan); } public List<CHITIET_THUCDON> DanhSachThucDon(int mathucdon) { return daoTD.DanhSachThucDon(mathucdon); } public bool XoaChiTiet(int ct) { return daoTD.XoaChiTiet(ct); } public bool XoaThucDon(THUCDON_NGAY td) { return daoTD.XoaThucDon(td); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/LapThucDonBus.cs
C#
asf20
1,193
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class HoaDonVeBUS { public static List<HOADON> layDSHoaDonVe() { return HoaDonVeDAO.layDSHoaDonVe(); } public static int layMaHDLonNhat() { return HoaDonVeDAO.layMaHDLonNhat(); } public static bool themHoaDon(HOADON hoaDon) { return HoaDonVeDAO.themHoaDon(hoaDon); } public static bool capNhatHoaDon(HOADON hoaDon) { return HoaDonVeDAO.capNhatHoaDon(hoaDon); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/HoaDonVeBUS.cs
C#
asf20
686
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class HoaDon_GiamGiaBUS { public static List<HOADON_GIAMGIA> layDSGG() { return HoaDon_GiamGiaDAO.layDSGG(); } public static double layTiLeGiamGia(int diemTichLuy) { return HoaDon_GiamGiaDAO.layTiLeGiamGia(diemTichLuy); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/HoaDon_GiamGiaBUS.cs
C#
asf20
463
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("BUS")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BUS")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("7cfb8245-79b7-4f2c-b19e-709a19671bb8")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/Properties/AssemblyInfo.cs
C#
asf20
1,418
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace BUS { public static class DanhSachVeBUS { public static List<DS_GIAVE> layDSGV() { return DanhSachVeDAO.layDSGV(); } public static DS_GIAVE layVe(int maVe) { return DanhSachVeDAO.layVe(maVe); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/BUS/DanhSachVeBUS.cs
C#
asf20
415
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class NguyenVatLieuDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<NGUYENVATLIEU> layDSNVL() { List<NGUYENVATLIEU> arrNVL = db.NGUYENVATLIEU.ToList(); return arrNVL; } public static NGUYENVATLIEU layNVL(int maNVL) { NGUYENVATLIEU nvl = db.NGUYENVATLIEU.Find(maNVL); return nvl; } public static int layMaNVLLonNhat() { try { int maNVL = db.NGUYENVATLIEU.Max(p => p.MaNVL); return maNVL; } catch (Exception ex) { return 0; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/NguyenVatLieuDAO.cs
C#
asf20
894
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class HoaDon_DiemTichLuyDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static int layDiemTichLuy(decimal tongTienHD) { if (tongTienHD < db.HOADON_DIEMTICHLUY.First().GiaTriDau) return 0; var gtc = db.HOADON_DIEMTICHLUY.Where(p => p.GiaTriCuoi >= tongTienHD).Min(p => p.GiaTriCuoi); int kq = db.HOADON_DIEMTICHLUY.Where(p => p.GiaTriCuoi == gtc).Single().DiemQuyDoi; return kq; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/HoaDon_DiemTichLuyDAO.cs
C#
asf20
683
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace DAO { public static class HoaDonVeDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<HOADON> layDSHoaDonVe() { List<HOADON> arrHoaDon = db.HOADON.ToList(); return arrHoaDon; } public static int layMaHDLonNhat() { try { int maHD = db.HOADON.Max(p => p.MaHD); return maHD; } catch (Exception ex) { return 0; } } public static bool themHoaDon(HOADON hoaDon) { try { db.HOADON.Add(hoaDon); db.SaveChanges(); return true; } catch (Exception ex) { return false; } } public static bool capNhatHoaDon(HOADON hoaDon) { try { HOADON hd = db.HOADON.Find(hoaDon.MaHD); hd.CTHD_VEBUFFET = hoaDon.CTHD_VEBUFFET; db.SaveChanges(); return true; } catch (Exception ex) { return false; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/HoaDonVeDAO.cs
C#
asf20
1,361
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public class NhanVienDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public bool dangNhap(int maNV, string matKhau) { bool ok = false; NHANVIEN nv = db.NHANVIEN.Find(maNV); if (nv != null) { if (nv.MatKhau == matKhau) { int loaiNV = nv.LoaiNV; switch (loaiNV) { case 1: ok = true; break; case 2: ok = true; break; case 3: ok = true; break; case 4: ok = true; break; case 5: ok = true; break; default: ok = false; break; } } } return ok; } public NHANVIEN layNV(int maNV) { NHANVIEN nv = new NHANVIEN(); nv = db.NHANVIEN.Find(maNV); return nv; } public List<NHANVIEN> LayDS_NV() { var nhanvien = db.NHANVIEN.ToList(); return nhanvien; } public List<LOAINHANVIEN> LayDS_Loai() { var Loai = db.LOAINHANVIEN.ToList(); return Loai; } public void CapNhat_NV(NHANVIEN nv) { var nhanvien = db.NHANVIEN.Find(nv.MaNV); nhanvien.TenNV = nv.TenNV; nhanvien.CMND = nv.CMND; nhanvien.DiaChi = nv.DiaChi; nhanvien.LoaiNV = nv.LoaiNV; nhanvien.DienThoai = nv.DienThoai; db.SaveChanges(); } public void Them_NV(NHANVIEN nv) { db.NHANVIEN.Add(nv); db.SaveChanges(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/NhanVienDAO.cs
C#
asf20
2,316
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class SanPhamDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<SANPHAM> layDSSP() { List<SANPHAM> arrSP = db.SANPHAM.ToList(); return arrSP; } public static SANPHAM laySP(int maSP) { SANPHAM sp = db.SANPHAM.Find(maSP); return sp; } public static void ThemSanPham(SANPHAM sanpham) { db.SANPHAM.Add(sanpham); db.SaveChanges(); } public static void CapNhatSanPham(SANPHAM sanpham) { var sp = db.SANPHAM.Where(k => k.MaSP == sanpham.MaSP).FirstOrDefault(); sp.TenSP = sanpham.TenSP; sp.GiaSP = sanpham.GiaSP; db.SaveChanges(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/SanPhamDAO.cs
C#
asf20
966
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; using System.Configuration; namespace DAO { public class DataProvider { private string _error; public string Error { get { return _error; } set { _error = value; } } private string _sqlConnectionstring; public string SqlConnectionstring { get { return _sqlConnectionstring; } set { _sqlConnectionstring = value; } } private SqlConnection _connect; public SqlConnection Connect { get { return _connect; } set { _connect = value; } } public DataProvider() { this._sqlConnectionstring = @"Data Source=.\SQLEXPRESS;Initial Catalog=QL_HuongRung;Integrated Security=True"; //this._sqlConnectionstring = ConfigurationManager.ConnectionStrings["QL_HuongRungEntitiesDB"].ToString(); this._connect = new SqlConnection(_sqlConnectionstring); this._error = ""; } public bool MoKetNoi() { try { if (_connect == null) { _connect = new SqlConnection(_sqlConnectionstring); } if (_connect.State == ConnectionState.Open) { _connect.Close(); } _connect.Open(); return true; } catch (SqlException ex) { throw new Exception("Không thể kết nối tới csdl"); _error = ex.Message; return false; } } public bool DongKetNoi() { try { if (_connect != null) { if (_connect.State == ConnectionState.Open) _connect.Close(); } return true; } catch (SqlException ex) { _error = ex.Message; } return false; } //Su dung proc public bool ExecuteNonQuery(string proc, SqlParameter[] sqlpram) { try { if (MoKetNoi()) { SqlCommand cmd = _connect.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; if (sqlpram != null) { cmd.Parameters.AddRange(sqlpram); } cmd.CommandText = proc; _error = ""; cmd.ExecuteNonQuery(); } return true; } catch (SqlException ex) { string[] chuoi = ex.Message.ToString().Split('.'); throw new Exception(chuoi[0].ToString()); } } /// <summary> /// Phuong thuc cho restore dữ liệu, truyền câu truy vấn /// </summary> /// <param name="proc"></param> /// <param name="sqlpram"></param> /// <returns></returns> public bool ExecuteNonQuery_Restore(string sql) { try { if (MoKetNoi()) { SqlCommand cmd = _connect.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = sql; _error = ""; cmd.ExecuteNonQuery(); } return true; } catch (SqlException ex) { string[] chuoi = ex.Message.ToString().Split('.'); throw new Exception(chuoi[0].ToString()); } } public DataTable ExecuteQuery(string proc, SqlParameter[] param) { DataTable dt = null; try { if (MoKetNoi()) { SqlCommand cmd = _connect.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; if (param != null) { cmd.Parameters.AddRange(param); } cmd.CommandText = proc; _error = ""; dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); } } catch (SqlException ex) { string[] chuoi = ex.Message.ToString().Split('.'); throw new Exception(chuoi[0].ToString()); //_error = ex.Message; } finally { DongKetNoi(); } return dt; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/DataProvider.cs
C#
asf20
5,217
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class DanhSachVeDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<DS_GIAVE> layDSGV() { List<DS_GIAVE> arrDSGV = db.DS_GIAVE.ToList(); return arrDSGV; } public static DS_GIAVE layVe(int maVe) { DS_GIAVE ve = db.DS_GIAVE.Find(maVe); return ve; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/DanhSachVeDAO.cs
C#
asf20
552
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public class LapThucDonDao { QL_HuongRungEntities db = new QL_HuongRungEntities(); public List<MonAnPublic> LayDS_MonAn() { var monan = from m in db.MONAN select new MonAnPublic { MaMonAn = m.MaMonAn, TenMonAn = m.TenMonAn }; return monan.ToList(); } public bool ThemThucDon(THUCDON_NGAY ThucDon) { try { db.THUCDON_NGAY.Add(ThucDon); db.SaveChanges(); return true; } catch (Exception) { return false; } } public void CapNhatChiTiet(CHITIET_THUCDON ThucDon) { try { // THUCDON_NGAY td = db.THUCDON_NGAY.Find(ThucDon.MaThucDon); // td.CHITIET_THUCDON = ThucDon.CHITIET_THUCDON; db.CHITIET_THUCDON.Add(ThucDon); db.SaveChanges(); } catch (Exception) { } } public List<ThucDonPublic> getWeek() { var week = from td in db.THUCDON_NGAY select new ThucDonPublic {Tuan = td.Tuan}; return week.Distinct().ToList(); } public List<ThucDonPublic> NgayTrongTuan(string tuan) { var ngay = from n in db.THUCDON_NGAY where tuan == n.Tuan select new ThucDonPublic { MaThucDon = n.MaThucDon,Tuan = n.Tuan, NgayTrongTuan = n.NgayTrongTuan, NgayLap = n.Ngay }; return ngay.ToList(); } public List<CHITIET_THUCDON> DanhSachThucDon(int mathucdon) { var ct = db.CHITIET_THUCDON.Where(p => p.MaThucDon == mathucdon).ToList(); return ct; } public bool XoaChiTiet(int ct) { try { db.Database.ExecuteSqlCommand("DELETE FROM CHITIET_THUCDON WHERE MaThucDon = {0}", ct); return true; } catch (Exception) { return false; } } public bool XoaThucDon(THUCDON_NGAY td) { try { THUCDON_NGAY thucdon = db.THUCDON_NGAY.Find(td.MaThucDon); db.THUCDON_NGAY.Remove(thucdon); db.SaveChanges(); return true; } catch (Exception) { return false; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/LapThucDonDao.cs
C#
asf20
2,608
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public class MonAnPublic { public int MaMonAn { get; set; } public string TenMonAn { get; set; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/MonAnPublic.cs
C#
asf20
250
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class MonAnDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static bool themMonAn(MONAN monan) { try { db.MONAN.Add(monan); db.SaveChanges(); return true; } catch (Exception ex) { return false; } } public static bool capNhatMonAn(MONAN monan) { try { MONAN temp = db.MONAN.Find(monan.MaMonAn); temp.TenMonAn = monan.TenMonAn; temp.DS_NVL_MONAN = monan.DS_NVL_MONAN; db.SaveChanges(); return true; } catch (Exception ex) { //Exception current = ex; //SqlException se = null; //do //{ // se = current.InnerException as SqlException; // current = current.InnerException; //} //while (current != null && se == null); return false; } } public static int layMaMonAnLonNhat () { try { int maMA = db.MONAN.Max(p => p.MaMonAn); return maMA; } catch (Exception ex) { return 0; } } public static List<MONAN> layDSMA () { List<MONAN> arrMA = db.MONAN.ToList(); return arrMA; } public static MONAN layMonAnDauTien() { return db.MONAN.First(); } public static MONAN layMonAn(int maMA) { return db.MONAN.Find(maMA); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/MonAnDAO.cs
C#
asf20
2,016
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public class ThucDonPublic { public int MaThucDon { get; set; } public string Tuan { get; set; } public System.DateTime NgayLap { get; set; } public string NgayTrongTuan { get; set; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/ThucDonPublic.cs
C#
asf20
353
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class HoaDon_GiamGiaDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<HOADON_GIAMGIA> layDSGG() { List<HOADON_GIAMGIA> arrHDGG = new List<HOADON_GIAMGIA>(); arrHDGG = db.HOADON_GIAMGIA.ToList(); return arrHDGG; } public static double layTiLeGiamGia(int diemTichLuy) { double tiLeGiamGia = 0; var temp = db.HOADON_GIAMGIA.Where(p => p.DiemTichLuy <= diemTichLuy) .Max(p => p.DiemTichLuy); tiLeGiamGia = db.HOADON_GIAMGIA.Where(p => p.DiemTichLuy == temp).Single().TiLeGiamGia; return tiLeGiamGia; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/HoaDon_GiamGiaDAO.cs
C#
asf20
867
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace DAO { public static class DBMS { } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/DBMS.cs
C#
asf20
190
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("DAO")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DAO")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("d3dcb558-4540-4894-9d87-38b199299bba")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/Properties/AssemblyInfo.cs
C#
asf20
1,418
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class KhachHangDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<KHACHHANG> layDSKH() { List<KHACHHANG> arrKH = db.KHACHHANG.ToList(); return arrKH; } public static KHACHHANG layKH(int maKH) { KHACHHANG kh = db.KHACHHANG.Find(maKH); return kh; } public static void ThemKhachHang(KHACHHANG kh) { db.KHACHHANG.Add(kh); db.SaveChanges(); } public static void CapNhatKhachHang(KHACHHANG kh) { var khachhang = db.KHACHHANG.Where(k => k.MaKH == kh.MaKH).FirstOrDefault(); khachhang.TenKH = kh.TenKH; khachhang.DiaChi = kh.DiaChi; khachhang.SoDienThoai = kh.SoDienThoai; khachhang.DiemTichLuy = kh.DiemTichLuy; db.SaveChanges(); } public static bool capNhatDiemTichLuy(KHACHHANG kh) { try { KHACHHANG temp = db.KHACHHANG.Find(kh.MaKH); temp.DiemTichLuy = kh.DiemTichLuy; db.SaveChanges(); return true; } catch (Exception ex) { return false; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/KhachHangDAO.cs
C#
asf20
1,500
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public static class HoaDonSPDAO { public static QL_HuongRungEntities db = new QL_HuongRungEntities(); public static List<HOADON_SP> layDSHDSP() { List<HOADON_SP> arrHDSP = db.HOADON_SP.ToList(); return arrHDSP; } public static int layMaHDLonNhat() { try { int maHD = db.HOADON_SP.Max(p => p.MaHDSP); return maHD; } catch (Exception ex) { return 0; } } public static bool themHoaDonSP(HOADON_SP hoaDonSP) { try { db.HOADON_SP.Add(hoaDonSP); db.SaveChanges(); return true; } catch (Exception ex) { return false; } } public static bool capNhatHoaDon(HOADON_SP hoaDon) { try { HOADON_SP hd = db.HOADON_SP.Find(hoaDon.MaHDSP); hd.CTHD_SP = hoaDon.CTHD_SP; db.SaveChanges(); return true; } catch (Exception ex) { return false; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/DAO/HoaDonSPDAO.cs
C#
asf20
1,362
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmHoaDonBar : DevComponents.DotNetBar.Office2007Form { frmMain formCha = new frmMain(); public frmHoaDonBar(frmMain frm) { InitializeComponent(); formCha = frm; } public bool loadXongForm = false; public bool hoanTat = false; public List<SANPHAM> arrSP = SanPhamBUS.layDSSP(); public KHACHHANG kh = new KHACHHANG(); double tiLeGiamGia = 0; public NHANVIEN nv = new NHANVIEN(); public void khoiTao() { lblNhanVien.Text = nv.TenNV; lblNgayGio.Text = DateTime.Now.ToString(); txtMaHD.Text = (HoaDonSPBUS.layMaHDLonNhat() + 1).ToString(); List<KHACHHANG> arrKH = KhachHangBUS.layDSKH(); cbbMaKH.DataSource = arrKH; cbbMaKH.ValueMember = "MaKH"; cbbMaKH.DisplayMember = "MaKH"; kh = arrKH[0]; txtTenKH.Text = kh.TenKH; cbbSP.DataSource = arrSP; cbbSP.DisplayMember = "TenSP"; cbbSP.ValueMember = "MaSP"; DataTable dt = new DataTable(); dt.Columns.Add("Mã"); dt.Columns.Add("Sản phẩm"); dt.Columns.Add("Đơn giá"); dt.Columns.Add("Số lượng"); dt.Columns.Add("Thành tiền"); dt.Columns[0].ReadOnly = true; dt.Columns[1].ReadOnly = true; dt.Columns[2].ReadOnly = true; dt.Columns[3].ReadOnly = true; dt.Columns[4].ReadOnly = true; grvCTHD.Refresh(); grvCTHD.DataSource = dt; grvCTHD.Columns[0].Visible = false; txtSoLuong.Text = ""; txtTongTien.Text = ""; } private void frmHoaDonBar_Load(object sender, EventArgs e) { khoiTao(); loadXongForm = true; } private void cbbMaKH_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { kh = KhachHangBUS.layKH(int.Parse(cbbMaKH.SelectedValue.ToString())); txtTenKH.Text = kh.TenKH; } } private void btnThemCTHD_Click(object sender, EventArgs e) { if (txtSoLuong.Text != "") { DataTable dt = ((DataTable)grvCTHD.DataSource).Copy(); bool trungCTHD = false; foreach (DataRow row in dt.Rows) { if (row[1] == cbbSP.Text) { dt.Columns[4].ReadOnly = false; dt.Columns[3].ReadOnly = false; row[3] = (int.Parse(row[3].ToString()) + int.Parse(txtSoLuong.Text)).ToString(); row[4] = double.Parse(row[2].ToString()) * int.Parse(row[3].ToString()); trungCTHD = true; break; } } if (!trungCTHD) { DataRow dr = dt.NewRow(); int soLuong = int.Parse(txtSoLuong.Text); SANPHAM sp = SanPhamBUS.laySP(int.Parse(cbbSP.SelectedValue.ToString())); dr[0] = sp.MaSP; dr[1] = sp.TenSP; dr[2] = sp.GiaSP; dr[3] = soLuong.ToString(); dr[4] = (soLuong * sp.GiaSP).ToString(); dt.Rows.Add(dr); } dt.Columns[3].ReadOnly = true; dt.Columns[4].ReadOnly = true; grvCTHD.DataSource = null; grvCTHD.DataSource = dt; tinhTongTam(dt); } else { MessageBox.Show("Bạn đưa nhập số lượng sản phẩm"); txtSoLuong.Focus(); } } public void tinhTongTam(DataTable dt) { double tongTien = 0; foreach (DataRow row in dt.Rows) { tongTien += double.Parse(row[4].ToString()); } txtTongTien.Text = tongTien.ToString(); } private void grvCTHD_CellValueChanged(object sender, DataGridViewCellEventArgs e) { int row = grvCTHD.CurrentCell.RowIndex; DataTable dt = ((DataTable)grvCTHD.DataSource).Copy(); int col = grvCTHD.CurrentCell.ColumnIndex; //MessageBox.Show(grvCTHD.Rows[row].Cells[col].Value.ToString()); } private void btnLapHD_Click(object sender, EventArgs e) { DataTable dt = ((DataTable)grvCTHD.DataSource).Copy(); if (dt.Rows.Count != 0) { //set up new order and insert HOADON_SP hoaDonSP = new HOADON_SP(); if (kh.MaKH != 1) { hoaDonSP.MaKH = kh.MaKH; } hoaDonSP.NgayLap = DateTime.Now; hoaDonSP.TriGia = decimal.Parse(txtTongTien.Text); hoaDonSP.NhanVienTao = nv.MaNV; hoaDonSP.TrangThai = true; bool result = HoaDonSPBUS.themHoaDonSP(hoaDonSP); if (result) { foreach (DataRow row in dt.Rows) { CTHD_SP cthd = new CTHD_SP(); cthd.MaHDSP = hoaDonSP.MaHDSP; cthd.MaSP = int.Parse(row[0].ToString()); cthd.SoLuong = int.Parse(row[3].ToString()); cthd.GiaSP = decimal.Parse(row[2].ToString()); hoaDonSP.CTHD_SP.Add(cthd); } result = HoaDonSPBUS.capNhatHoaDon(hoaDonSP); if (result) { //cập nhật điểm tích lũy if (kh.MaKH != 1) { result = capNhatDiemTichLuy(kh, hoaDonSP.TriGia); } if (result) { MessageBox.Show("Lập hóa đơn thành công"); hoanTat = true; khoiTao(); } else { MessageBox.Show("Lập hóa đơn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Lập hóa đơn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Lập hóa đơn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Chưa nhập vé"); } } private void btnHuy_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Bạn có thực sự muốn tắt màn hình lập hóa đơn?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Hóa đơn Bar"); tab.TabPages.RemoveAt(index); } } else { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Hóa đơn Bar"); tab.TabPages.RemoveAt(index); } } private void btnXoa_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Hóa đơn chưa lập xong. Bạn có thực sự muốn lập hóa đơn mới?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { khoiTao(); } } else khoiTao(); } private void txtSoLuong_KeyPress(object sender, KeyPressEventArgs e) { const char Delete = (char)8; e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete; } public bool capNhatDiemTichLuy(KHACHHANG kh, decimal tongTienHD) { int diemTichLuy = HoaDon_DiemTichLuyBUS.layDiemTichLuy(tongTienHD); kh.DiemTichLuy = kh.DiemTichLuy + diemTichLuy; return KhachHangBUS.capNhatDiemTichLuy(kh); } private void cbbSP_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { txtSoLuong.Text = ""; } } static int KiemTraTonTai(TabControl TabControlName, string TabName) { int temp = -1; for (int i = 0; i < TabControlName.TabPages.Count; i++) { if (TabControlName.TabPages[i].Text == TabName) { temp = i; break; } } return temp; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmHoaDonBar.cs
C#
asf20
10,277
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DAO; namespace GUI { class test { //NHANVIEN nv = new NHANVIEN(); //QL_HuongRungEntities db = new QL_HuongRungEntities(); } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/test.cs
C#
asf20
262
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmCapNhatMonAn : DevComponents.DotNetBar.Office2007Form { frmMain formCha = new frmMain(); public frmCapNhatMonAn(frmMain main) { InitializeComponent(); formCha = main; } public NHANVIEN nv = new NHANVIEN(); public List<NGUYENVATLIEU> arrNVL = NguyenVatLieuBUS.layDSNVL(); public bool loadXongForm = false; public bool hoanTat = false; public List<MONAN> arrMA = MonAnBUS.layDSMA(); public void khoiTao() { lblNhanVien.Text = nv.TenNV; cbbMonAn.DataSource = arrMA; cbbMonAn.DisplayMember = "TenMonAn"; cbbMonAn.ValueMember = "MaMonAn"; MONAN monan = MonAnBUS.layMonAn(int.Parse(cbbMonAn.SelectedValue.ToString())); txtTenMonAn.Text = monan.TenMonAn; cbbNVL.DataSource = arrNVL; cbbNVL.DisplayMember = "TenNVL"; cbbNVL.ValueMember = "MaNVL"; grvNVLCT.Refresh(); grvNVLCT.DataSource = MonAnBUS.layNVLMonAnDauTien(); grvNVLCT.Columns[0].Visible = false; txtSoLuong.Text = ""; } private void frmCapNhatMonAn_Load(object sender, EventArgs e) { khoiTao(); loadXongForm = true; } private void cbbNVL_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { NGUYENVATLIEU nvl = NguyenVatLieuBUS.layNVL(int.Parse(cbbNVL.SelectedValue.ToString())); lblDonViTinh.Text = nvl.DonViTinh; txtSoLuong.Text = ""; } } private void cbbMonAn_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { MONAN monan = MonAnBUS.layMonAn(int.Parse(cbbMonAn.SelectedValue.ToString())); txtTenMonAn.Text = monan.TenMonAn; grvNVLCT.Refresh(); grvNVLCT.DataSource = MonAnBUS.layNVLMonAn(monan.MaMonAn); grvNVLCT.Columns[0].Visible = false; txtSoLuong.Text = ""; } } private void btnDong_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Bạn có thực sự muốn tắt màn hình thêm món ăn?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Cập nhật món ăn"); tab.TabPages.RemoveAt(index); } } else { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Cập nhật món ăn"); tab.TabPages.RemoveAt(index); } } private void btnXoaTruongDL_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Món ăn chưa được lưu cập nhật. Bạn có thực sự muốn dừng?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //trả lại ban đầu của món ăn đó, load dl món ăn từ cbb MONAN monan = MonAnBUS.layMonAn(int.Parse(cbbMonAn.SelectedValue.ToString())); txtTenMonAn.Text = monan.TenMonAn; grvNVLCT.Refresh(); grvNVLCT.DataSource = MonAnBUS.layNVLMonAn(monan.MaMonAn); grvNVLCT.Columns[0].Visible = false; txtSoLuong.Text = ""; } } else khoiTao(); } private void btnCapNhatMonAn_Click(object sender, EventArgs e) { DataTable dt = ((DataTable)grvNVLCT.DataSource).Copy(); if (dt.Rows.Count != 0) { if (txtTenMonAn.Text == "") { MessageBox.Show("Bạn chưa nhập tên món ăn"); txtTenMonAn.Focus(); return; } MONAN monan = new MONAN(); monan.TenMonAn = txtTenMonAn.Text; monan.MaMonAn = int.Parse(cbbMonAn.SelectedValue.ToString()); foreach (DataRow row in dt.Rows) { DS_NVL_MONAN nvl_ma = new DS_NVL_MONAN(); nvl_ma.MaMonAn = monan.MaMonAn; nvl_ma.MaNVL = int.Parse(row[0].ToString()); nvl_ma.SoLuongNVLCan = double.Parse(row[2].ToString()); monan.DS_NVL_MONAN.Add(nvl_ma); } bool kq = MonAnBUS.capNhatMonAn(monan); if (kq) { MessageBox.Show("Cập nhật món ăn thành công"); hoanTat = true; khoiTao(); } else { MessageBox.Show("Cập nhật món ăn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Bạn chưa nhập nguyên vật liệu cần thiết cho món ăn"); } } private void btnThêmNVLCT_Click(object sender, EventArgs e) { if (txtSoLuong.Text != "") { DataTable dt = ((DataTable)grvNVLCT.DataSource).Copy(); bool trungNVL = false; foreach (DataRow row in dt.Rows) { if (row[1] == cbbNVL.Text) { row[2] = txtSoLuong.Text; trungNVL = true; break; } } if (!trungNVL) { DataRow dr = dt.NewRow(); NGUYENVATLIEU nvl = NguyenVatLieuDAO.layNVL(int.Parse(cbbNVL.SelectedValue.ToString())); dr[0] = nvl.MaNVL; dr[1] = nvl.TenNVL; dr[2] = txtSoLuong.Text; dt.Rows.Add(dr); } grvNVLCT.DataSource = null; grvNVLCT.DataSource = dt; grvNVLCT.Columns[0].Visible = false; } } private void grvNVLCT_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (grvNVLCT.CurrentCell != null && grvNVLCT.CurrentCell.Value != null) { cbbNVL.Text = grvNVLCT.Rows[grvNVLCT.CurrentRow.Index].Cells[1].Value.ToString(); txtSoLuong.Text = grvNVLCT.Rows[grvNVLCT.CurrentRow.Index].Cells[2].Value.ToString(); } } } private void txtSoLuong_KeyPress(object sender, KeyPressEventArgs e) { const char Delete = (char)8; e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete && e.KeyChar != ','; } static int KiemTraTonTai(TabControl TabControlName, string TabName) { int temp = -1; for (int i = 0; i < TabControlName.TabPages.Count; i++) { if (TabControlName.TabPages[i].Text == TabName) { temp = i; break; } } return temp; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmCapNhatMonAn.cs
C#
asf20
8,382
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmThemMonAn : DevComponents.DotNetBar.Office2007Form { frmMain formCha = new frmMain(); public frmThemMonAn(frmMain frm) { InitializeComponent(); formCha = frm; } public NHANVIEN nv = new NHANVIEN(); public List<NGUYENVATLIEU> arrNVL = NguyenVatLieuBUS.layDSNVL(); public bool loadXongForm = false; public bool hoanTat = false; public void khoiTao() { lblNhanVien.Text = nv.TenNV; txtMaMonAn.Text = (MonAnBUS.layMaMonAnLonNhat() + 1).ToString(); cbbNVL.DataSource = arrNVL; cbbNVL.DisplayMember = "TenNVL"; cbbNVL.ValueMember = "MaNVL"; DataTable dt = new DataTable(); dt.Columns.Add("Mã"); dt.Columns.Add("Tên NVL"); dt.Columns.Add("Số lượng"); dt.Columns[0].ReadOnly = true; dt.Columns[1].ReadOnly = true; dt.Columns[2].ReadOnly = true; grvNVLCT.Refresh(); grvNVLCT.DataSource = dt; grvNVLCT.Columns[0].Visible = false; txtSoLuong.Text = ""; } private void frmThemMonAn_Load(object sender, EventArgs e) { khoiTao(); loadXongForm = true; } private void cbbNVL_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { NGUYENVATLIEU nvl = NguyenVatLieuBUS.layNVL(int.Parse(cbbNVL.SelectedValue.ToString())); lblDonViTinh.Text = nvl.DonViTinh; txtSoLuong.Text = ""; } } private void txtSoLuong_KeyPress(object sender, KeyPressEventArgs e) { const char Delete = (char)8; e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete && e.KeyChar != ','; } private void btnThêmNVLCT_Click(object sender, EventArgs e) { if (txtSoLuong.Text != "") { DataTable dt = ((DataTable)grvNVLCT.DataSource).Copy(); bool trungNVL = false; foreach (DataRow row in dt.Rows) { if (row[1] == cbbNVL.Text) { row[2] = txtSoLuong.Text; trungNVL = true; break; } } if (!trungNVL) { DataRow dr = dt.NewRow(); NGUYENVATLIEU nvl = NguyenVatLieuDAO.layNVL(int.Parse(cbbNVL.SelectedValue.ToString())); dr[0] = nvl.MaNVL; dr[1] = nvl.TenNVL; dr[2] = txtSoLuong.Text; dt.Rows.Add(dr); } grvNVLCT.DataSource = null; grvNVLCT.DataSource = dt; grvNVLCT.Columns[0].Visible = false; } } private void btnDong_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Bạn có thực sự muốn tắt màn hình thêm món ăn?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Thêm món ăn"); tab.TabPages.RemoveAt(index); } } else { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Thêm món ăn"); tab.TabPages.RemoveAt(index); } } private void btnXoaTruongDL_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Món ăn chưa được lưu. Bạn có thực sự muốn thêm món ăn khác?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { khoiTao(); } } else khoiTao(); } private void btnThemMonAn_Click(object sender, EventArgs e) { DataTable dt = ((DataTable)grvNVLCT.DataSource).Copy(); if (dt.Rows.Count != 0) { if (txtTenMonAn.Text == "") { MessageBox.Show("Bạn chưa nhập tên món ăn"); txtTenMonAn.Focus(); return; } MONAN monan = new MONAN(); monan.TenMonAn = txtTenMonAn.Text; bool kq = MonAnBUS.themMonAn(monan); if (kq) { foreach (DataRow row in dt.Rows) { DS_NVL_MONAN nvl_ma = new DS_NVL_MONAN(); nvl_ma.MaMonAn = monan.MaMonAn; nvl_ma.MaNVL = int.Parse(row[0].ToString()); nvl_ma.SoLuongNVLCan = double.Parse(row[2].ToString()); monan.DS_NVL_MONAN.Add(nvl_ma); } kq = MonAnBUS.capNhatMonAn(monan); if (kq) { MessageBox.Show("Thêm món ăn thành công"); hoanTat = true; khoiTao(); } else { MessageBox.Show("Thêm món ăn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Thêm món ăn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Bạn chưa nhập nguyên vật liệu cần thiết cho món ăn"); } } private void grvNVLCT_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (grvNVLCT.CurrentCell != null && grvNVLCT.CurrentCell.Value != null) { cbbNVL.Text = grvNVLCT.Rows[grvNVLCT.CurrentRow.Index].Cells[1].Value.ToString(); txtSoLuong.Text = grvNVLCT.Rows[grvNVLCT.CurrentRow.Index].Cells[2].Value.ToString(); } } } static int KiemTraTonTai(TabControl TabControlName, string TabName) { int temp = -1; for (int i = 0; i < TabControlName.TabPages.Count; i++) { if (TabControlName.TabPages[i].Text == TabName) { temp = i; break; } } return temp; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmThemMonAn.cs
C#
asf20
7,710
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace GUI { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmDangNhap()); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/Program.cs
C#
asf20
501
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmXemThucDon : Form { public frmXemThucDon() { InitializeComponent(); } private void frmXemThucDon_Load(object sender, EventArgs e) { layTuan(); khoitaocbbNgay(); } private void khoitaocbbNgay() { cbbNgay.Items.Clear(); for (int i = 2; i < 8; i++) { cbbNgay.Items.Add("Thứ "+i); } cbbNgay.Items.Add("Chủ Nhật"); cbbNgay.SelectedIndex = 0; HienThiNgay(); } private void HienThiNgay() { try { if (gvDSNgay.RowCount < 1) { return; } for (int i = 0; i < gvDSNgay.RowCount; i++) { cbbNgay.Items.Remove(gvDSNgay.Rows[i].Cells[3].Value.ToString()); } cbbNgay.SelectedIndex = 0; } catch (Exception) { } } List<ThucDonPublic> week = new List<ThucDonPublic>(); public void layTuan() { LapThucDonBus busTD = new LapThucDonBus(); week = busTD.getWeek(); cbbTuan.DataSource = week; cbbTuan.DisplayMember = "Tuan"; cbbTuan.ValueMember = "Tuan"; } List<ThucDonPublic> arrdate = new List<ThucDonPublic>(); private void cbbTuan_SelectedIndexChanged(object sender, EventArgs e) { chon(); } private void chon() { LapThucDonBus busTD = new LapThucDonBus(); string tuan = cbbTuan.SelectedValue.ToString().Trim(); arrdate = busTD.NgayTrongTuan(tuan); gvDSNgay.DataSource = arrdate; if (gvDSNgay.Rows.Count > 0) { int ma = int.Parse(gvDSNgay.Rows[0].Cells["clMaThucDon"].Value.ToString()); DanhSachThucDon(ma); btnNgay.Enabled = true; btnXoaNgay.Enabled = true; } if (gvDSNgay.Rows.Count >= 7) { btnNgay.Enabled = false; } khoitaocbbNgay(); } private void gvDSNgay_CellClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (rowIndex >= 0) { hienthi(); } } public void DanhSachThucDon(int mathucdon) { gvDSMonAn.Rows.Clear(); LapThucDonBus busTD = new LapThucDonBus(); List<CHITIET_THUCDON> arrChiTiet = busTD.DanhSachThucDon(mathucdon); for (int i = 0; i < arrChiTiet.Count; i++) { DataGridViewRow _newRow = (DataGridViewRow)gvDSMonAn.Rows[0].Clone(); _newRow.Cells[0].Value = arrChiTiet[i].MaThucDon; _newRow.Cells[1].Value = arrChiTiet[i].MaMonAn; _newRow.Cells[2].Value = arrChiTiet[i].MONAN.TenMonAn; _newRow.Cells[3].Value = arrChiTiet[i].SoPhanAn; gvDSMonAn.Rows.Add(_newRow); } } private void gvDSNgay_KeyPress(object sender, KeyPressEventArgs e) { hienthi(); } public void hienthi() { try { if (gvDSNgay.Rows.Count < 1) return; int ma = int.Parse(gvDSNgay.CurrentRow.Cells["clMaThucDon"].Value.ToString()); DanhSachThucDon(ma); } catch (Exception) { } } private void gvDSNgay_KeyDown(object sender, KeyEventArgs e) { hienthi(); } private void gvDSNgay_KeyUp(object sender, KeyEventArgs e) { hienthi(); } private void btnThemNgay_Click(object sender, EventArgs e) { ThemThucDon(); khoitaocbbNgay(); pnNgayTrongTuan.Visible = false; } public void ThemThucDon() { THUCDON_NGAY ThucDon = new THUCDON_NGAY(); LapThucDonBus busTD = new LapThucDonBus(); ThucDon.Ngay = Convert.ToDateTime(gvDSNgay.Rows[0].Cells[2].Value.ToString()); ThucDon.NgayTrongTuan = cbbNgay.Text; ThucDon.Tuan = gvDSNgay.Rows[0].Cells[1].Value.ToString(); bool result = busTD.ThemThucDon(ThucDon); if (result) { chon(); // string mathucdon = ThucDon.MaThucDon.ToString(); List<string> td = new List<string>(); td.Add(ThucDon.MaThucDon.ToString()); td.Add(ThucDon.Tuan.ToString()); td.Add(ThucDon.NgayTrongTuan); td.Add("i"); frmLapThucDon frm = new frmLapThucDon(td); frm.ShowDialog(); chon(); } } private void btnNgay_Click(object sender, EventArgs e) { pnNgayTrongTuan.Visible = true; //HienThiNgay(); khoitaocbbNgay(); } private void btnHuyNgay_Click(object sender, EventArgs e) { pnNgayTrongTuan.Visible = false; } private void btnCapNhat_Click(object sender, EventArgs e) { THUCDON_NGAY ThucDon = new THUCDON_NGAY(); ThucDon.MaThucDon = int.Parse(gvDSNgay.CurrentRow.Cells[0].Value.ToString()); ThucDon.Ngay = Convert.ToDateTime(gvDSNgay.CurrentRow.Cells[2].Value.ToString()); ThucDon.NgayTrongTuan = gvDSNgay.CurrentRow.Cells[3].Value.ToString(); ThucDon.Tuan = gvDSNgay.CurrentRow.Cells[1].Value.ToString(); List<string> td = new List<string>(); td.Add(ThucDon.MaThucDon.ToString()); td.Add(ThucDon.Tuan.ToString()); td.Add(ThucDon.NgayTrongTuan); td.Add("u"); frmLapThucDon frm = new frmLapThucDon(td); frm.ShowDialog(); chon(); } private void btnXoaNgay_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Bạn Thật Sự Muốn Xoá Ngày?, Danh Sách Các Món Ăn Trong Ngày Sẻ Bị Xoá?", "Cảnh Báo!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { LapThucDonBus busTD = new LapThucDonBus(); THUCDON_NGAY ThucDon = new THUCDON_NGAY(); ThucDon.MaThucDon = int.Parse(gvDSNgay.CurrentRow.Cells[0].Value.ToString()); busTD.XoaChiTiet(ThucDon.MaThucDon); Boolean temp = busTD.XoaThucDon(ThucDon); if (temp) { MessageBox.Show("Xoá Thành Công"); chon(); //HienThiNgay(); khoitaocbbNgay(); } } else if (dialogResult == DialogResult.No) { return; } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmXemThucDon.cs
C#
asf20
7,729
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; namespace GUI { public class GetWeek { public int GetWeekOrderInYear() { DateTime time = System.DateTime.Now; CultureInfo myCI = CultureInfo.CurrentCulture; Calendar myCal = myCI.Calendar; CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule; DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek; return myCal.GetWeekOfYear(time, myCWR, myFirstDOW); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/GetWeek.cs
C#
asf20
619
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmDangNhap : DevComponents.DotNetBar.Office2007Form { public frmDangNhap() { InitializeComponent(); } public bool isDangNhapThanhCong = false; NhanVienBUS NhanVienBUS = new NhanVienBUS(); private void btnHuy_Click(object sender, EventArgs e) { this.Close(); } private void btnDangNhap_Click(object sender, EventArgs e) { if (txtMaNV.Text == "") { MessageBox.Show("Nhập mã nhân viên"); txtMaNV.Focus(); } else if (txtMatKhau.Text == "") { MessageBox.Show("Nhập mật khẩu"); txtMatKhau.Focus(); } else { //tiến hành kiểm tra để đăng nhập int maNV = int.Parse(txtMaNV.Text); string matKhau = md5.maHoaMd5(txtMatKhau.Text); NhanVienBUS NhanVienBUS = new NhanVienBUS(); if (NhanVienBUS.dangNhap(maNV, matKhau)) { isDangNhapThanhCong = true; //nhanvien = NhanVienBUS.layNV(maNV); this.Hide(); frmMain frmChinh = new frmMain(); frmChinh.nhanvien = NhanVienBUS.layNV(maNV); frmChinh.ShowDialog(); } else { MessageBox.Show("Sai mật khẩu hay mã nhân viên. Vui lòng điền thông tin chính xác."); txtMaNV.Text = ""; txtMatKhau.Text = ""; txtMaNV.Focus(); } } } private void frmDangNhap_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmDangNhap.cs
C#
asf20
2,343
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmTheKhachHang : DevComponents.DotNetBar.Office2007Form { public frmTheKhachHang() { InitializeComponent(); } KHACHHANG kh = new KHACHHANG(); public void HienThi() { kh.MaKH = Int32.Parse(dgvKH.SelectedRows[0].Cells[0].Value.ToString()); kh.TenKH = dgvKH.SelectedRows[0].Cells[1].Value.ToString(); kh.SoDienThoai = dgvKH.SelectedRows[0].Cells[2].Value.ToString(); kh.DiaChi = dgvKH.SelectedRows[0].Cells[3].Value.ToString(); kh.DiemTichLuy = Convert.ToInt32(dgvKH.SelectedRows[0].Cells[4].Value.ToString()); txtMaKH.Text = kh.MaKH.ToString(); txtDiaChi.Text = kh.DiaChi; txtTenKH.Text = kh.TenKH; txtSDT.Text = kh.SoDienThoai; cbbDTL.Text = kh.DiemTichLuy.ToString(); } private void frmTheKhachHang_Load(object sender, EventArgs e) { cbbDTL.SelectedIndex = 0; } private void btnLapThe_Click(object sender, EventArgs e) { kh.TenKH = txtTenKH.Text; kh.DiaChi = txtDiaChi.Text; kh.SoDienThoai = txtSDT.Text; switch (cbbDTL.SelectedIndex) { case 0: kh.DiemTichLuy = 10; break; case 1: kh.DiemTichLuy = 25; break; case 2: kh.DiemTichLuy = 40; break; case 3: kh.DiemTichLuy = 55; break; case 4: kh.DiemTichLuy = 70; break; case 5: kh.DiemTichLuy = 90; break; default: kh.DiemTichLuy = 120; break; } KhachHangBUS.ThemKhachHang(kh); dgvKH.DataSource = KhachHangBUS.layDSKH(); } private void btnCapNhat_Click(object sender, EventArgs e) { kh.TenKH = txtTenKH.Text; kh.DiaChi = txtDiaChi.Text; kh.SoDienThoai = txtSDT.Text; switch (cbbDTL.SelectedIndex) { case 0: kh.DiemTichLuy = 10; break; case 1: kh.DiemTichLuy = 25; break; case 2: kh.DiemTichLuy = 40; break; case 3: kh.DiemTichLuy = 55; break; case 4: kh.DiemTichLuy = 70; break; case 5: kh.DiemTichLuy = 90; break; default: kh.DiemTichLuy = 120; break; } KhachHangBUS.CapNhatKhachHang(kh); dgvKH.DataSource = KhachHangBUS.layDSKH(); } private void dgvKH_CellClick(object sender, DataGridViewCellEventArgs e) { HienThi(); } private void dgvKH_KeyDown(object sender, KeyEventArgs e) { HienThi(); } private void dgvKH_KeyUp(object sender, KeyEventArgs e) { HienThi(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmTheKhachHang.cs
C#
asf20
3,765
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using BUS; using DAO; namespace GUI { public partial class frmHoaDonVe : DevComponents.DotNetBar.Office2007Form { frmMain formCha = new frmMain(); public frmHoaDonVe(frmMain frm) { InitializeComponent(); formCha = frm; } public bool loadXongForm = false; public bool hoanTat = false; public List<DS_GIAVE> arrDSGV = DanhSachVeBUS.layDSGV(); public KHACHHANG kh = new KHACHHANG(); double tiLeGiamGia; public NHANVIEN nv = new NHANVIEN(); public void khoiTao() { lblNhanVien.Text = nv.TenNV; lblNgayGio.Text = DateTime.Now.ToString(); txtMaHD.Text = (HoaDonVeBUS.layMaHDLonNhat() + 1).ToString(); List<KHACHHANG> arrKH = KhachHangBUS.layDSKH(); cbbMaKH.DataSource = arrKH; cbbMaKH.ValueMember = "MaKH"; cbbMaKH.DisplayMember = "MaKH"; kh = arrKH[0]; txtTenKH.Text = kh.TenKH; cbbVe.DataSource = arrDSGV; cbbVe.DisplayMember = "TenVe"; cbbVe.ValueMember = "MaVe"; DataTable dt = new DataTable(); dt.Columns.Add("Mã"); dt.Columns.Add("Loại vé"); dt.Columns.Add("Giá vé"); dt.Columns.Add("Số lượng"); dt.Columns.Add("Thành tiền"); dt.Columns[0].ReadOnly = true; dt.Columns[1].ReadOnly = true; dt.Columns[2].ReadOnly = true; dt.Columns[3].ReadOnly = true; dt.Columns[4].ReadOnly = true; grvCTHD.Refresh(); grvCTHD.DataSource = dt; grvCTHD.Columns[0].Visible = false; txtSoLuong.Text = ""; txtTongTam.Text = "0"; txtTongTien.Text = "0"; txtGiamGia.Text = "Không giảm giá"; } private void frmHoaDonVe_Load(object sender, EventArgs e) { khoiTao(); loadXongForm = true; } private void cbbMaKH_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { kh = KhachHangBUS.layKH(int.Parse(cbbMaKH.SelectedValue.ToString())); txtTenKH.Text = kh.TenKH; if (kh.MaKH == 1) { txtGiamGia.Text = "Không giảm giá"; txtTongTien.Text = txtTongTam.Text; } else { int diemTichLuy = (int)kh.DiemTichLuy; tiLeGiamGia = HoaDon_GiamGiaBUS.layTiLeGiamGia(diemTichLuy); txtGiamGia.Text = tiLeGiamGia.ToString() + "%"; double tongTam = double.Parse(txtTongTam.Text); txtTongTien.Text = (tongTam - (tongTam * (tiLeGiamGia / 100))).ToString(); } } } private void txtSoLuong_KeyPress(object sender, KeyPressEventArgs e) { const char Delete = (char)8; e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete; } private void btnThemCTHD_Click(object sender, EventArgs e) { if (txtSoLuong.Text != "") { DataTable dt = ((DataTable)grvCTHD.DataSource).Copy(); bool trungCTHD = false; foreach (DataRow row in dt.Rows) { if (row[1] == cbbVe.Text) { dt.Columns[4].ReadOnly = false; dt.Columns[3].ReadOnly = false; row[3] = (int.Parse(row[3].ToString()) + int.Parse(txtSoLuong.Text)).ToString(); row[4] = double.Parse(row[2].ToString()) * int.Parse(row[3].ToString()); trungCTHD = true; break; } } if (!trungCTHD) { DataRow dr = dt.NewRow(); int soLuong = int.Parse(txtSoLuong.Text); DS_GIAVE ve = DanhSachVeBUS.layVe(int.Parse(cbbVe.SelectedValue.ToString())); dr[0] = ve.MaVe; dr[1] = ve.TenVe; dr[2] = ve.GiaTien; dr[3] = soLuong.ToString(); dr[4] = (soLuong * ve.GiaTien).ToString(); dt.Rows.Add(dr); } dt.Columns[3].ReadOnly = true; dt.Columns[4].ReadOnly = true; grvCTHD.DataSource = null; grvCTHD.DataSource = dt; tinhTongTam(dt); } else { MessageBox.Show("Bạn đưa nhập số lượng vé"); txtSoLuong.Focus(); } } public void tinhTongTam(DataTable dt) { double tongTam = 0; foreach (DataRow row in dt.Rows) { tongTam += double.Parse(row[4].ToString()); } txtTongTam.Text = tongTam.ToString(); if (kh.MaKH == 1) { txtGiamGia.Text = "Không giảm giá"; txtTongTien.Text = tongTam.ToString(); } else { int diemTichLuy = (int)kh.DiemTichLuy; tiLeGiamGia = HoaDon_GiamGiaBUS.layTiLeGiamGia(diemTichLuy); txtGiamGia.Text = tiLeGiamGia.ToString() + "%"; txtTongTien.Text = (tongTam - (tongTam * (tiLeGiamGia / 100))).ToString(); } } private void btnHuy_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Bạn có thực sự muốn tắt màn hình lập hóa đơn?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Hóa đơn Vé"); tab.TabPages.RemoveAt(index); } } else { TabControl tab = (TabControl)(formCha.Controls["tabControlMain"]); int index = KiemTraTonTai(tab, "Hóa đơn Vé"); tab.TabPages.RemoveAt(index); } } private void btnLapHD_Click(object sender, EventArgs e) { DataTable dt = ((DataTable)grvCTHD.DataSource).Copy(); if (dt.Rows.Count != 0) { //set up new order and insert HOADON hoaDonVe = new HOADON(); if (kh.MaKH != 1) { hoaDonVe.MaKH = kh.MaKH; } hoaDonVe.NgapLap = DateTime.Now; hoaDonVe.TriGia = decimal.Parse(txtTongTam.Text); hoaDonVe.GiamGia = tiLeGiamGia; hoaDonVe.TongTienThat = decimal.Parse(txtTongTien.Text); hoaDonVe.NhanVienTao = nv.MaNV; hoaDonVe.TrangThai = true; bool result = HoaDonVeBUS.themHoaDon(hoaDonVe); if (result) { foreach (DataRow row in dt.Rows) { CTHD_VEBUFFET cthd = new CTHD_VEBUFFET(); cthd.MaHD = hoaDonVe.MaHD; cthd.MaVe = int.Parse(row[0].ToString()); cthd.SoLuong = int.Parse(row[3].ToString()); cthd.GiaVe = decimal.Parse(row[2].ToString()); hoaDonVe.CTHD_VEBUFFET.Add(cthd); } result = HoaDonVeBUS.capNhatHoaDon(hoaDonVe); if (kh.MaKH != 1) { result = capNhatDiemTichLuy(kh, hoaDonVe.TriGia); } if (result) { MessageBox.Show("Lập hóa đơn thành công"); hoanTat = true; khoiTao(); } else { MessageBox.Show("Lập hóa đơn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Lập hóa đơn không thành công. Vui lòng thử lại."); hoanTat = true; khoiTao(); } } else { MessageBox.Show("Chưa nhập vé"); } } private void btnXoa_Click(object sender, EventArgs e) { if (!hoanTat) { DialogResult dialogResult = MessageBox.Show("Hóa đơn chưa lập xong. Bạn có thực sự muốn lập hóa đơn mới?", "Xác nhận", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { khoiTao(); } } else khoiTao(); } public bool capNhatDiemTichLuy(KHACHHANG kh, decimal tongTienHD) { int diemTichLuy = HoaDon_DiemTichLuyBUS.layDiemTichLuy(tongTienHD); kh.DiemTichLuy = kh.DiemTichLuy + diemTichLuy; return KhachHangBUS.capNhatDiemTichLuy(kh); } private void cbbVe_SelectedIndexChanged(object sender, EventArgs e) { if (loadXongForm) { txtSoLuong.Text = ""; } } static int KiemTraTonTai(TabControl TabControlName, string TabName) { int temp = -1; for (int i = 0; i < TabControlName.TabPages.Count; i++) { if (TabControlName.TabPages[i].Text == TabName) { temp = i; break; } } return temp; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmHoaDonVe.cs
C#
asf20
10,769
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmLapThucDon : Form { private BindingSource bs = new BindingSource(); //private BindingSource DSChon = new BindingSource(); List<string> dd = new List<string>(); public frmLapThucDon(List<string> td) { InitializeComponent(); dd = td; } List<CHITIET_THUCDON> arrChiTiet = new List<CHITIET_THUCDON>(); public void DanhSachMonAn_HienTai(int mathucdon) { gvDSMonAn.Rows.Clear(); LapThucDonBus busTD = new LapThucDonBus(); arrChiTiet = busTD.DanhSachThucDon(mathucdon); for (int i = 0; i < arrChiTiet.Count; i++) { DataGridViewRow _newRow = (DataGridViewRow)gvDSChon.Rows[0].Clone(); // _newRow.Cells[0].Value = arrChiTiet[i].MaThucDon; _newRow.Cells[0].Value = arrChiTiet[i].MaMonAn; _newRow.Cells[1].Value = arrChiTiet[i].MONAN.TenMonAn; _newRow.Cells[2].Value = arrChiTiet[i].SoPhanAn; gvDSChon.Rows.Add(_newRow); } } public void LayDS_MonAn() { LapThucDonBus busTD = new LapThucDonBus(); List<MonAnPublic> MonAn = new List<MonAnPublic>(); MonAn = busTD.LayDS_MonAn(); if (dd[3] == "u") { for (int i = 0; i < arrChiTiet.Count; i++) { for (int j = 0; j < MonAn.Count; j++) { if (arrChiTiet[i].MaMonAn == MonAn[j].MaMonAn) MonAn.RemoveAt(j); } } } foreach(var row in MonAn) { DataGridViewRow _newRow = (DataGridViewRow)gvDSMonAn.Rows[0].Clone(); _newRow.Cells[0].Value = row.MaMonAn; _newRow.Cells[1].Value = row.TenMonAn; gvDSMonAn.Rows.Add(_newRow); } } int tuanthu = 0; int year = DateTime.Now.Year; string week = ""; private void frmLapThucDon_Load(object sender, EventArgs e) { if (int.Parse(dd[0]) != 0) { txtTuan.Text = dd[1]; lbThu.Text = dd[2]; btnNgayTiep.Visible = false; if (dd[3] == "u") { DanhSachMonAn_HienTai(int.Parse(dd[0])); LayDS_MonAn(); btnLuu.Enabled = true; } else LayDS_MonAn(); } else { LayDS_MonAn(); TuanTrongNam(); } } public void TuanTrongNam() { GetWeek tuan = new GetWeek(); tuanthu = tuan.GetWeekOrderInYear(); tuanthu = tuanthu + 1; if (tuanthu > 52) { tuanthu++; year++; } week = tuanthu + "_" + year; txtTuan.Text = week.ToString(); } private void btnNext_Click(object sender, EventArgs e) { if (gvDSChon.RowCount >= 1) { btnLuu.Enabled = true; } foreach (DataGridViewRow item in this.gvDSMonAn.SelectedRows) { if(!item.IsNewRow) { DataGridViewRow row = gvDSMonAn.Rows[item.Index]; DataGridViewRow _newRow = (DataGridViewRow)gvDSChon.Rows[0].Clone(); _newRow.Cells[0].Value = int.Parse(row.Cells[0].Value.ToString()); _newRow.Cells[1].Value = row.Cells[1].Value.ToString(); _newRow.Cells[2].Value = 10; gvDSChon.Rows.Add(_newRow); gvDSMonAn.Rows.Remove(gvDSMonAn.CurrentRow); } } } private void gvDSMonAn_CellClick(object sender, DataGridViewCellEventArgs e) { } private void panel1_Paint(object sender, PaintEventArgs e) { } private void btnPre_Click(object sender, EventArgs e) { foreach (DataGridViewRow item in this.gvDSChon.SelectedRows) { if (!item.IsNewRow) { DataGridViewRow row = gvDSChon.Rows[item.Index]; DataGridViewRow _newRow = (DataGridViewRow)gvDSMonAn.Rows[0].Clone(); _newRow.Cells[0].Value = int.Parse(row.Cells[0].Value.ToString()); _newRow.Cells[1].Value = row.Cells[1].Value.ToString(); gvDSMonAn.Rows.Add(_newRow); // gvDSChon.Rows.RemoveAt(item.Index); gvDSChon.Rows.Remove(gvDSChon.CurrentRow); } } if (gvDSChon.RowCount <= 1) { btnLuu.Enabled = false; } } private void gvDSMonAn_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { btnNext_Click(null, null); } private void gvDSChon_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { btnPre_Click(null, null); } int ngay = 2; private void btnNgayTiep_Click(object sender, EventArgs e) { if (gvDSChon.RowCount > 1) { DialogResult dialogResult = MessageBox.Show("Danh Sách Chưa lưu, Bạn Thật Sự Muốn Qua Ngày Tiếp Theo?", "Cảnh Báo!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { ChuyenNgay(); } else if (dialogResult == DialogResult.No) { return; } } else ChuyenNgay(); } public void ChuyenNgay() { ngay++; btnLuu.Enabled = false; //btnNgayTiep.Enabled = false; if (ngay == 8) { lbThu.Text = "Chủ Nhật"; btnNgayTiep.Enabled = false; } else lbThu.Text = "Thứ " + ngay; gvDSMonAn.Rows.Clear(); LayDS_MonAn(); gvDSChon.Rows.Clear(); //string t = gvDSChon.RowCount.ToString(); // MessageBox.Show(t); result = false; } private bool temp = false; public bool kiemtrathucdontuan() { LapThucDonBus busDS = new LapThucDonBus(); List<ThucDonPublic> arrthucdon = new List<ThucDonPublic>(); arrthucdon = busDS.NgayTrongTuan(txtTuan.Text.Trim()); if (arrthucdon.Count > 0) { MessageBox.Show("Danh Sách Thực Đơn Tuần Này Đã Được Lập, Xin Chọn Chức Năng Quản Lý Thực Đơn Để Kiểm Tra!", "Thông Báo!"); return false; } return true; } private void btnLuu_Click(object sender, EventArgs e) { if((int.Parse(dd[0]) != 0)) { if (dd[3] == "u") { LapThucDonBus busDT = new LapThucDonBus(); busDT.XoaChiTiet(int.Parse(dd[0])); } ThemCT_ThucDon(int.Parse(dd[0])); btnLuu.Enabled = false; gvDSMonAn.Enabled = false; MessageBox.Show("Thành Công!"); } else { if (!temp) { temp = kiemtrathucdontuan(); } if (temp) { if (!result) { ThemThucDon(); } if (result) { ThemCT_ThucDon(ThucDon.MaThucDon); } btnLuu.Enabled = false; // btnNgayTiep.Enabled = true; gvDSMonAn.Rows.Clear(); LayDS_MonAn(); gvDSChon.Rows.Clear(); if (ngay >= 8) { MessageBox.Show("Hoàn Thành Lập Thực Đơn"); btnNgayTiep.Enabled = false; gvDSMonAn.Enabled = false; } else btnNgayTiep_Click(null, null); } } } THUCDON_NGAY ThucDon = new THUCDON_NGAY(); bool result = false; public void ThemThucDon() { LapThucDonBus busTD = new LapThucDonBus(); ThucDon.Ngay = Convert.ToDateTime(dtpNagyLap.Text); ThucDon.NgayTrongTuan = lbThu.Text; ThucDon.Tuan = txtTuan.Text; result = busTD.ThemThucDon(ThucDon); } public void ThemCT_ThucDon(int maThucDon) { if (result || (int.Parse(dd[0]) != 0)) { LapThucDonBus busCTTD = new LapThucDonBus(); for (int i = 0; i < this.gvDSChon.RowCount-1; i++) { CHITIET_THUCDON CT = new CHITIET_THUCDON(); CT.MaThucDon = maThucDon; CT.MaMonAn = int.Parse(gvDSChon.Rows[i].Cells[0].Value.ToString()); CT.SoPhanAn = int.Parse(gvDSChon.Rows[i].Cells[2].Value.ToString()); busCTTD.CapNhatChiTiet(CT); } } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmLapThucDon.cs
C#
asf20
10,439
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("GUI")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("GUI")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("acd46ad8-3688-44b7-9d1f-b8bd803eccc7")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/Properties/AssemblyInfo.cs
C#
asf20
1,418
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmSanPham : DevComponents.DotNetBar.Office2007Form { public frmSanPham() { InitializeComponent(); } SANPHAM sanpham = new SANPHAM(); public void HienThi() { sanpham.MaSP = Convert.ToInt32(dgvDSSP.SelectedRows[0].Cells[0].Value.ToString()); sanpham.TenSP = dgvDSSP.SelectedRows[0].Cells[1].Value.ToString(); sanpham.GiaSP = Convert.ToDecimal(dgvDSSP.SelectedRows[0].Cells[2].Value.ToString()); txtMaSP.Text = sanpham.MaSP.ToString(); txtTenSP.Text = sanpham.TenSP; txtGiaSP.Text = sanpham.GiaSP.ToString(); } private void frmSanPham_Load(object sender, EventArgs e) { dgvDSSP.DataSource = SanPhamBUS.layDSSP(); dgvDSSP.Columns[3].Visible = false; dgvDSSP.Columns[4].Visible = false; } private void btnCapNhat_Click(object sender, EventArgs e) { sanpham.TenSP = txtTenSP.Text; sanpham.GiaSP = Convert.ToDecimal(txtGiaSP.Text); SanPhamBUS.CapNhatSanPham(sanpham); dgvDSSP.DataSource = SanPhamBUS.layDSSP(); txtMaSP.Text = null; txtTenSP.Text = null; txtGiaSP.Text = null; } private void btnThem_Click(object sender, EventArgs e) { sanpham.TenSP = txtTenSP.Text; sanpham.GiaSP = Convert.ToDecimal(txtGiaSP.Text); SanPhamBUS.ThemSanPham(sanpham); SanPhamBUS.layDSSP(); dgvDSSP.DataSource = SanPhamBUS.layDSSP(); txtMaSP.Text = null; txtTenSP.Text = null; txtGiaSP.Text = null; } private void dgvDSVe_CellClick(object sender, DataGridViewCellEventArgs e) { HienThi(); } private void dgvDSVe_KeyDown(object sender, KeyEventArgs e) { HienThi(); } private void dgvDSVe_KeyUp(object sender, KeyEventArgs e) { HienThi(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmSanPham.cs
C#
asf20
2,405
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GUI { public static class md5 { public static byte[] encryptData(string data) { System.Security.Cryptography.MD5CryptoServiceProvider md5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] hashedBytes; System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(data)); return hashedBytes; } public static string maHoaMd5(string data) { return BitConverter.ToString(encryptData(data)).Replace("-", "").ToLower(); } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/md5.cs
C#
asf20
759
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmMain : DevComponents.DotNetBar.Office2007RibbonForm { public frmMain() { InitializeComponent(); } public NHANVIEN nhanvien = new NHANVIEN(); private void frmMain_Load(object sender, EventArgs e) { switch (nhanvien.LoaiNV) { case 1: //quản lý btnThemMonAn.Enabled = true; btnCapNhatMonAn.Enabled = true; btnLapTheKH.Enabled = true; btnThemHDVe.Enabled = true; btnThemHDBar.Enabled = true; btnThongKe.Enabled = true; btnPCBep.Enabled = true; btnPCPV.Enabled = true; break; case 2: //bếp trưởng btnThemMonAn.Enabled = true; btnCapNhatMonAn.Enabled = true; btnThongKe.Enabled = true; break; case 3: //thu ngân btnLapTheKH.Enabled = true; btnThemHDVe.Enabled = true; btnThemHDBar.Enabled = true; btnThongKe.Enabled = true; break; case 4: //thu mua btnThongKe.Enabled = true; break; case 5: //kho btnThongKe.Enabled = true; break; default: break; } } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } private void btnThemHDBar_Click(object sender, EventArgs e) { frmHoaDonBar frm = new frmHoaDonBar(this); frm.nv = nhanvien; TabCreating(tabControlMain, "Hóa đơn Bar", frm); } private void btnThemHDVe_Click(object sender, EventArgs e) { frmHoaDonVe frm = new frmHoaDonVe(this); frm.nv = nhanvien; TabCreating(tabControlMain, "Hóa đơn Vé", frm); } private void btnThemMonAn_Click(object sender, EventArgs e) { frmThemMonAn frm = new frmThemMonAn(this); frm.nv = nhanvien; TabCreating(tabControlMain, "Thêm món ăn", frm); } private void btnCapNhatMonAn_Click(object sender, EventArgs e) { frmCapNhatMonAn frm = new frmCapNhatMonAn(this); frm.nv = nhanvien; TabCreating(tabControlMain, "Cập nhật món ăn", frm); } private void btnDangXuat_Click(object sender, EventArgs e) { this.Hide(); frmDangNhap frm = new frmDangNhap(); frm.ShowDialog(); } public void TabCreating(TabControl TabControl, string Text, Form Form) { int Index = KiemTraTonTai(TabControl, Text); if (Index >= 0) { TabControl.SelectedTab = TabControl.TabPages[Index]; TabControl.SelectedTab.Text = Text; } else { TabPage TabPage = new TabPage { Text = Text }; TabControl.TabPages.Add(TabPage); TabControl.SelectedTab = TabPage; Form.TopLevel = false; Form.Parent = TabPage; Form.Show(); Form.Dock = DockStyle.Fill; } } static int KiemTraTonTai(TabControl TabControlName, string TabName) { int temp = -1; for (int i = 0; i < TabControlName.TabPages.Count; i++) { if (TabControlName.TabPages[i].Text == TabName) { temp = i; break; } } return temp; } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/Form1.cs
C#
asf20
4,316
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DAO; using BUS; namespace GUI { public partial class frmQuanLyNhanVien : DevComponents.DotNetBar.Office2007Form { public frmQuanLyNhanVien() { InitializeComponent(); } private void frmQuanLyNhanVien_Load(object sender, EventArgs e) { LayDS_Loai(); LayDS_NV(); lbNgay.Text = DateTime.Now.ToShortDateString(); } public void LayDS_Loai() { NhanVienBUS busNV = new NhanVienBUS(); List<LOAINHANVIEN> arrLoai = busNV.LayDS_Loai(); cbbLoaiNV.DataSource = arrLoai; cbbLoaiNV.DisplayMember = "TenLoaiNV"; cbbLoaiNV.ValueMember = "MaLoaiNV"; } public void LayDS_NV() { gvNhanVien.Rows.Clear(); NhanVienBUS busNV = new NhanVienBUS(); List<NHANVIEN> arrNhanVien = busNV.LayDS_NV(); for (int i = 0; i < arrNhanVien.Count; i++) { DataGridViewRow _newRow = (DataGridViewRow)gvNhanVien.Rows[0].Clone(); _newRow.Cells[0].Value = arrNhanVien[i].MaNV; _newRow.Cells[1].Value = arrNhanVien[i].TenNV; _newRow.Cells[2].Value = arrNhanVien[i].CMND; _newRow.Cells[3].Value = arrNhanVien[i].DienThoai; _newRow.Cells[4].Value = arrNhanVien[i].DiaChi; _newRow.Cells[5].Value = arrNhanVien[i].LOAINHANVIEN.MaLoaiNV; _newRow.Cells[6].Value = arrNhanVien[i].LOAINHANVIEN.TenLoaiNV; gvNhanVien.Rows.Add(_newRow); } } private void gbThemNV_Enter(object sender, EventArgs e) { } private void txtCMND_TextChanged(object sender, EventArgs e) { } private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e) { } public void clear() { txtTenNV.Text = ""; txtCMND.Text = ""; txtDiaChi.Text = ""; txtSDT.Text = ""; } private void button1_Click(object sender, EventArgs e) { if (kiemtra()) { NHANVIEN nv = new NHANVIEN(); nv.MaNV = MaNV_Sua; nv.TenNV = txtTenNV.Text; nv.CMND = txtCMND.Text; nv.DiaChi = txtDiaChi.Text; nv.DienThoai = txtSDT.Text; nv.LoaiNV = int.Parse(cbbLoaiNV.SelectedValue.ToString()); //NhanVienBUS bus = new NhanVienBUS(); NhanVienBUS busNV = new NhanVienBUS(); busNV.CapNhat_NV(nv); clear(); LayDS_NV(); pnThemNhanVien.Visible = false; } } int MaNV_Sua; private void gvNhanVien_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (rowIndex >= 0 && rowIndex < gvNhanVien.RowCount - 1) { pnThemNhanVien.Visible = true; btnCapNhatNV.Visible = true; btnThemNV.Visible = false; btnThem.Enabled = true; DataGridViewRow row = gvNhanVien.Rows[rowIndex]; MaNV_Sua = int.Parse(row.Cells["clMaNV"].Value.ToString()); txtTenNV.Text = row.Cells["clTenNV"].Value.ToString(); txtCMND.Text = row.Cells["clCMND"].Value.ToString(); txtDiaChi.Text = row.Cells["clDiaChi"].Value.ToString(); txtSDT.Text = row.Cells["clDT"].Value.ToString(); cbbLoaiNV.SelectedValue = int.Parse(row.Cells["clMaLoai"].Value.ToString()); } } private void btnThem_Click(object sender, EventArgs e) { clear(); pnThemNhanVien.Visible = true; btnThemNV.Visible = true; btnCapNhatNV.Visible = false; btnThem.Enabled = false; } private void btnHuy_Click(object sender, EventArgs e) { clear(); pnThemNhanVien.Visible = false; btnThem.Enabled = true; } private void btnDong_Click(object sender, EventArgs e) { clear(); pnThemNhanVien.Visible = false; btnThem.Enabled = true; } private bool kiemtra() { if (string.IsNullOrEmpty(txtTenNV.Text)) { MessageBox.Show("Nhập Tên Nhân Viên!"); return false; } if (string.IsNullOrEmpty(txtCMND.Text)) { MessageBox.Show("Nhập Số CNMD!"); return false; } return true; } private void btnThemNV_Click(object sender, EventArgs e) { if (kiemtra()) { NHANVIEN nv = new NHANVIEN(); nv.MaNV = 0; nv.TenNV = txtTenNV.Text; nv.CMND = txtCMND.Text; nv.MatKhau = md5.maHoaMd5(txtCMND.Text); nv.DiaChi = txtDiaChi.Text; nv.DienThoai = txtSDT.Text; nv.LoaiNV = int.Parse(cbbLoaiNV.SelectedValue.ToString()); nv.TinhTrang = true; NhanVienBUS busNV = new NhanVienBUS(); busNV.Them_NV(nv); clear(); LayDS_NV(); } } } }
12hcbqlhuongrungbuffet05
trunk/source/HuongRungBuffet/GUI/frmQuanLyNhanVien.cs
C#
asf20
5,936
using System; using System.Collections.Generic; using System.Text; namespace DataProvider { public class DatabaseExc:Exception { public DatabaseExc(string message) : base(message) { } private int errCodeSQL = 0; private int errCodeUser = 0; public int ErrCodeSQL { get { return errCodeSQL; } set { errCodeSQL = value; } } public int ErrCodeUser { get { return errCodeUser; } set { errCodeUser = value; } } public DatabaseExc(string message, int errCodeSQL) : base(message) { this.errCodeSQL = errCodeSQL; } public DatabaseExc(string message, int errCodeUser, int errCodeSQL) : base(message) { this.errCodeSQL = errCodeSQL; this.errCodeUser = errCodeUser; } } }
0871152qlhs
trunk/QLHS_Souce_Code/DataProvider/DatabaseExc.cs
C#
gpl2
1,061
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("DataProvider")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Heaven")] [assembly: AssemblyProduct("DataProvider")] [assembly: AssemblyCopyright("Copyright © Heaven 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("0eacd7c9-73e4-4df4-9a3b-8d39bb47e097")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0871152qlhs
trunk/QLHS_Souce_Code/DataProvider/Properties/AssemblyInfo.cs
C#
gpl2
1,407
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace BaoCao { public class Transparency { public class TransparencyForm { private Timer timer1; private bool open; private Form frm; public bool Open { get { return this.open; } set { this.open = value; } } public int Interval { get { return this.timer1.Interval; } set { this.timer1.Interval = value; } } public double Opacity { get { return this.frm.Opacity; } set { this.frm.Opacity = value; } } public TransparencyForm(Form frm, bool open, int interval, double intialOpacity) { try { this.frm = frm; this.timer1 = new Timer(); this.timer1.Tick += new EventHandler(timer1_Tick); this.Open = open; this.Interval = interval; this.Opacity = intialOpacity; } catch { } } private void timer1_Tick(object sender, EventArgs e) { this.frm.Show(); if (this.Open) ProcessStart(); else ProcessClear(); } private void ProcessClear() { this.Opacity -= 0.1; if (this.Opacity <= 0) { this.Stop(); this.frm.Hide(); } } private void ProcessStart() { this.Opacity += 0.1; if (this.Opacity >= 0.9) { this.Stop(); this.open = false; } } public void Start() { this.timer1.Enabled = true; } public void Stop() { this.timer1.Enabled = false; } } } }
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/Transparency.cs
C#
gpl2
2,446
namespace BaoCao { partial class DataSetQLHS { partial class DMLOPDataTable { } } }
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/DataSetQLHS.cs
C#
gpl2
135
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace BaoCao { class ProcessError { public static void SaveErr(string pathFileName, string[] arrStrErr) { StreamWriter wr = new StreamWriter(pathFileName, true, Encoding.Unicode); wr.WriteLine("-----" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "-----"); for (int i = 0; i < arrStrErr.Length; i++) wr.WriteLine(arrStrErr[i]); wr.WriteLine(""); wr.Close(); } } }
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/ProcessError.cs
C#
gpl2
616
using System; using System.Collections.Generic; using System.Windows.Forms; namespace BaoCao { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } } }
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/Program.cs
C#
gpl2
475
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("BaoCao")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Heaven")] [assembly: AssemblyProduct("BaoCao")] [assembly: AssemblyCopyright("Copyright © Heaven 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("68581dbb-5899-4232-8b0b-0d166a597827")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/Properties/AssemblyInfo.cs
C#
gpl2
1,272
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using XComponent.Windows.MACUI; namespace BaoCao { public partial class frmInfomationBaoCao : Form { public frmInfomationBaoCao() { InitializeComponent(); } } }
0871152qlhs
trunk/QLHS_Souce_Code/BaoCao/frmInfomationBaoCao.cs
C#
gpl2
392
using System; using System.Collections.Generic; using System.Text; using Bussiness.Interfaces; using System.Data; using DataProvider; using Bussiness.Exc; namespace Bussiness { public class INBAOCAOProcess:IINBAOCAO { IDBManager idbManager = new DBManager(DataProviderE.SqlServer); DataTable IINBAOCAO.XemThang() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemThang()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemLop() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemLop()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemNamHoc(string maLop) { DataTable tbl = null; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@Malop", maLop, ParameterDirection.Input); idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemNamHoc(string maLop)" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemNamHoc() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemNamHoc()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemHocKy(byte hocKy) { DataTable tbl = null; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@HocKy", hocKy, ParameterDirection.Input); idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemHocKy(byte hocKy)" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemHocKy() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemHocKy()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemThang(string maKT) { DataTable tbl = null; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@MaKT", maKT, ParameterDirection.Input); idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemThang(string maKT)" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable IINBAOCAO.XemPhieuDiemThang() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemThang()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/INBAOCAOProcess.cs
C#
gpl2
6,393
using System; using System.Collections.Generic; using System.Text; using Bussiness.Interfaces; using Bussiness.Data; using DataProvider; using System.Data; using System.Data.SqlClient; using Bussiness.Exc; namespace Bussiness { public class DMKHOIProcess:IDMKHOI { IDBManager idbManager = new DBManager(DataProviderE.SqlServer); DataTable IDMKHOI.XemDMKHOI() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spDMKHOIXem").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IDMKHOI.XemDMKHOI()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } bool IDMKHOI.ThemDMKHOI(DMKHOI dmkhoi) { bool success = false; try { idbManager.CreateParameters(2); idbManager.AddParameters(0, "@Makhoi", dmkhoi.Makhoi, ParameterDirection.Input); idbManager.AddParameters(1, "@Tenkhoi", dmkhoi.Tenkhoi, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spDMKHOIThem"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IDMKHOI.ThemDMKHOI(DMKHOI dmkhoi)" + e.Message); } finally { idbManager.Dispose(); } return success; } bool IDMKHOI.XoaDMKHOI(string makhoiValue) { bool success = false; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@Makhoi", makhoiValue, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spDMKHOIXoa"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IDMMON.XoaDMMON(string makhoinValue)" + e.Message); } finally { idbManager.Dispose(); } return success; } bool IDMKHOI.UpdateDMKHOI(DMKHOI dmkhoi) { bool success = false; try { idbManager.CreateParameters(2); idbManager.AddParameters(0, "@Makhoi", dmkhoi.Makhoi, ParameterDirection.Input); idbManager.AddParameters(1, "@Tenkhoi", dmkhoi.Tenkhoi, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spDMKHOIUpdate"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. IDMKHOI.UpdateDMKHOI(DMKHOI dmkhoi)" + e.Message); } finally { idbManager.Dispose(); } return success; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/DMKHOIProcess.cs
C#
gpl2
4,100
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Interfaces; using DataProvider; using Bussiness.Exc; namespace Bussiness { public class NHAPDIEM_SUBProcess:INHAPDIEM_SUB { IDBManager idbManager = new DBManager(DataProviderE.SqlServer); DataTable INHAPDIEM_SUB.HocSinhTheoLop(string malop) { DataTable dtb; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@malop", malop, ParameterDirection.Input); idbManager.Open(); dtb = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spHOCSINHTHEOLOPXem").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. INHAPDIEM_SUB.HocSinhTheoLop(string malop)" + e.Message); } finally { idbManager.Dispose(); } return dtb; } DataTable INHAPDIEM_SUB.MonTheoLop(string malop) { DataTable dtb; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@malop", malop, ParameterDirection.Input); idbManager.Open(); dtb = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spMONTHEOLOPXem").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. INHAPDIEM_SUB.HocSinhTheoLop(string malop)" + e.Message); } finally { idbManager.Dispose(); } return dtb; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/NHAPDIEM_SUBProcess.cs
C#
gpl2
2,082
using System; using System.Collections.Generic; using System.Text; using Bussiness.Data; using DataProvider; using System.Data; using System.Data.SqlClient; using Bussiness.Exc; namespace Bussiness.Interfaces { public class LOAIKTRAProcess:ILOAIKTRA { IDBManager idbManager = new DBManager(DataProviderE.SqlServer); DataTable ILOAIKTRA.XemLOAIKTRA() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spLOAIKTRAXem").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ILOAIKTRA.XemLOAIKTRA()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } bool ILOAIKTRA.ThemLOAIKTRA(LOAIKTRA loaiKTra) { bool success = false; try { idbManager.CreateParameters(4); idbManager.AddParameters(0, "@Hocky", loaiKTra.HocKy, ParameterDirection.Input); idbManager.AddParameters(1, "@Makt", loaiKTra.MaKT, ParameterDirection.Input); idbManager.AddParameters(2, "@Tenkt", loaiKTra.TenKT, ParameterDirection.Input); idbManager.AddParameters(3, "@Heso", loaiKTra.HeSo, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spLOAIKTRAThem"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ILOAIKTRA.ThemLOAIKTRA(LOAIKTRA loaiKTra)" + e.Message); } finally { idbManager.Dispose(); } return success; } bool ILOAIKTRA.XoaLOAIKTRA(byte hockyValue,string maKTraValue) { bool success = false; try { idbManager.CreateParameters(2); idbManager.AddParameters(0, "@Hocky", hockyValue, ParameterDirection.Input); idbManager.AddParameters(1, "@Makt", maKTraValue, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spLOAIKTRAXoa"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ILOAIKTRA.XoaLOAIKTRA(string maKTraValue)" + e.Message); } finally { idbManager.Dispose(); } return success; } bool ILOAIKTRA.UpdateLOAIKTRA(LOAIKTRA loaiKTra) { bool success = false; try { idbManager.CreateParameters(4); idbManager.AddParameters(0, "@Hocky", loaiKTra.HocKy, ParameterDirection.Input); idbManager.AddParameters(1, "@Makt", loaiKTra.MaKT, ParameterDirection.Input); idbManager.AddParameters(2, "@Tenkt", loaiKTra.TenKT, ParameterDirection.Input); idbManager.AddParameters(3, "@Heso", loaiKTra.HeSo, ParameterDirection.Input); idbManager.Open(); int isuccess = idbManager.ExecuteNonQuery(CommandType.StoredProcedure, "spLOAIKTRAUpdate"); if (isuccess > 0) success = true; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ILOAIKTRA.UpdateLOAIKTRA(LOAIKTRA loaiKTra)" + e.Message); } finally { idbManager.Dispose(); } return success; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/LOAIKTRAProcess.cs
C#
gpl2
4,631
using System; using System.Collections.Generic; using System.Text; namespace Bussiness { public enum EnumLoaiUsers { Admins=0, ReportedUsers=1, NormalUsers=2, None=3 } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/EnumLoaiUsers.cs
C#
gpl2
229
using System; using System.Collections.Generic; using System.Text; using Bussiness.Data; using System.Data; namespace Bussiness.Interfaces { public interface ICTKTRA { DtsCTKTRA XemCTKTRA(); bool UpdateSP(DtsCTKTRA dtsSP); DataTable XemDMLOP(); DataTable XemLOAIKTRA(byte hocky); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/ICTKTRA.cs
C#
gpl2
345
using System; using System.Collections.Generic; using System.Text; using Bussiness.Data; using System.Data; namespace Bussiness.Interfaces { public interface IHOCSINH { DataTable XemHOCSINHTab3(string mahsValue); DataTable XemHOCSINH(); bool ThemHOCSINH(HOCSINH hocsinh); bool XoaHOCSINH(string mahsValue); bool UpdateHOCSINH(HOCSINH hocsinh); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/IHOCSINH.cs
C#
gpl2
418
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Data; namespace Bussiness.Interfaces { public interface ILOGGIN { DataTable XemUSERS(byte maloaiUser); bool ThemUSERS(byte maloaiUser, LOGGIN loggin); bool XoaUSERS(byte maloaiUser, string userID); bool UpdateUSERS(byte maloaiUser, LOGGIN loggin); EnumLoaiUsers Loggin(LOGGIN loggin); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/ILOGGIN.cs
C#
gpl2
461
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Data; namespace Bussiness.Interfaces { public interface IDMLOP { DataTable XemDMLOP(); DataTable XemMakhoi(); bool ThemDMLOP(DMLOP dmlop); bool XoaDMLOP(string malopValue); bool UpdateDMLOP(DMLOP dmlop); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/IDMLOP.cs
C#
gpl2
380
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Data; namespace Bussiness.Interfaces { public interface IDMMON { DataTable XemDMMON(); bool ThemDMMON(DMMON dmmon); bool XoaDMMON(string mamonValue); bool UpdateDMMON(DMMON dmmon); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/IDMMON.cs
C#
gpl2
348
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Data; namespace Bussiness.Interfaces { public interface ILOAIKTRA { DataTable XemLOAIKTRA(); bool ThemLOAIKTRA(LOAIKTRA loaiKTra); bool XoaLOAIKTRA(byte hockyValue, string maKTraValue); bool UpdateLOAIKTRA(LOAIKTRA loaiKTra); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/ILOAIKTRA.cs
C#
gpl2
393
using System; using System.Collections.Generic; using System.Text; using Bussiness.Data; using System.Data; namespace Bussiness.Interfaces { public interface IDMKHOI { DataTable XemDMKHOI(); bool ThemDMKHOI(DMKHOI dmkhoi); bool XoaDMKHOI(string makhoiValue); bool UpdateDMKHOI(DMKHOI dmkhoi); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/IDMKHOI.cs
C#
gpl2
358
using System; using System.Collections.Generic; using System.Text; using System.Data; using Bussiness.Data; namespace Bussiness.Interfaces { public interface IINBAOCAO { DataTable XemThang(); DataTable XemLop(); DataTable XemPhieuDiemNamHoc(string maLop); DataTable XemPhieuDiemNamHoc(); DataTable XemPhieuDiemHocKy(byte hocKy); DataTable XemPhieuDiemHocKy(); DataTable XemPhieuDiemThang(string maKT); DataTable XemPhieuDiemThang(); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/IINBAOCAO.cs
C#
gpl2
534
using System; using System.Collections.Generic; using System.Text; using System.Data; namespace Bussiness.Interfaces { public interface INHAPDIEM_SUB { DataTable HocSinhTheoLop(string malop); DataTable MonTheoLop(string malop); } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Interfaces/INHAPDIEM_SUB.cs
C#
gpl2
274
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Bussiness")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Heaven")] [assembly: AssemblyProduct("Bussiness")] [assembly: AssemblyCopyright("Copyright © Heaven 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("cefc4394-7b63-48e0-bb3b-5518bf263657")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Properties/AssemblyInfo.cs
C#
gpl2
1,401
using System; using System.Collections.Generic; using System.Text; using System.Data; using DataProvider; using Bussiness.Data; using Bussiness.Exc; using Bussiness.Interfaces; namespace Bussiness { public class CTKTRAProcess:ICTKTRA { IDBManager idbManager = new DBManager(DataProviderE.SqlServer); DtsCTKTRA ICTKTRA.XemCTKTRA() { DtsCTKTRA dtsCTKTRA = new DtsCTKTRA(); try { idbManager.Open(); dtsCTKTRA.Tables.Add(idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spCTKTRAXem").Tables[0].Copy()); } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ICTKTRA.XemCTKTRA()" + e.Message); } finally { idbManager.Dispose(); } return dtsCTKTRA; } bool ICTKTRA.UpdateSP(DtsCTKTRA dtsCTKTRA) { bool success = false; try { IDataParameter[] arrParamInsert = DBManagerFactory.GetParameters(idbManager.ProviderType, 7); arrParamInsert[0] = DBManagerFactory.GetParameterSQL("@RETURN_VALUE", SqlDbType.Variant, 0, System.Data.ParameterDirection.ReturnValue, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null); arrParamInsert[1] = DBManagerFactory.GetParameterSQL("@Hocky", SqlDbType.TinyInt, 0, "Hocky"); arrParamInsert[2] = DBManagerFactory.GetParameterSQL("@Mahs", SqlDbType.NChar, 0, "Mahs"); arrParamInsert[3] = DBManagerFactory.GetParameterSQL("@Mamon", SqlDbType.NChar, 0, "Mamon"); arrParamInsert[4] = DBManagerFactory.GetParameterSQL("@Makt", SqlDbType.NChar, 0, "Makt"); arrParamInsert[5] = DBManagerFactory.GetParameterSQL("@Diem", System.Data.SqlDbType.Decimal, 0, System.Data.ParameterDirection.Input, false, ((byte)(4)), ((byte)(2)), "Diem", System.Data.DataRowVersion.Current, null); arrParamInsert[6] = DBManagerFactory.GetParameterSQL("@Malop", System.Data.SqlDbType.NChar, 0, "Malop"); IDataParameter[] arrParamUpdate = DBManagerFactory.GetParameters(idbManager.ProviderType, 11); arrParamUpdate[0] = DBManagerFactory.GetParameterSQL("@RETURN_VALUE", System.Data.SqlDbType.Variant, 0, System.Data.ParameterDirection.ReturnValue, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null); arrParamUpdate[1] = DBManagerFactory.GetParameterSQL("@Hocky", System.Data.SqlDbType.TinyInt, 0, "Hocky"); arrParamUpdate[2] = DBManagerFactory.GetParameterSQL("@Mahs", System.Data.SqlDbType.NChar, 0, "Mahs"); arrParamUpdate[3] = DBManagerFactory.GetParameterSQL("@Mamon", System.Data.SqlDbType.NChar, 0, "Mamon"); arrParamUpdate[4] = DBManagerFactory.GetParameterSQL("@Makt", System.Data.SqlDbType.NChar, 0, "Makt"); arrParamUpdate[5] = DBManagerFactory.GetParameterSQL("@Diem", System.Data.SqlDbType.Decimal, 0, System.Data.ParameterDirection.Input, false, ((byte)(4)), ((byte)(2)), "Diem", System.Data.DataRowVersion.Current, null); arrParamUpdate[6] = DBManagerFactory.GetParameterSQL("@Malop", System.Data.SqlDbType.NChar, 0, "Malop"); arrParamUpdate[7] = DBManagerFactory.GetParameterSQL("@Original_Hocky", System.Data.SqlDbType.TinyInt, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Hocky", System.Data.DataRowVersion.Original, null); arrParamUpdate[8] = DBManagerFactory.GetParameterSQL("@Original_Mahs", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Mahs", System.Data.DataRowVersion.Original, null); arrParamUpdate[9] = DBManagerFactory.GetParameterSQL("@Original_Mamon", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Mamon", System.Data.DataRowVersion.Original, null); arrParamUpdate[10] = DBManagerFactory.GetParameterSQL("@Original_Makt", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Makt", System.Data.DataRowVersion.Original, null); IDataParameter[] arrParamDelete = DBManagerFactory.GetParameters(idbManager.ProviderType, 5); arrParamDelete[0] = DBManagerFactory.GetParameterSQL("@RETURN_VALUE", System.Data.SqlDbType.Variant, 0, System.Data.ParameterDirection.ReturnValue, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null); arrParamDelete[1] = DBManagerFactory.GetParameterSQL("@Original_Hocky", System.Data.SqlDbType.TinyInt, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Hocky", System.Data.DataRowVersion.Original, null); arrParamDelete[2] = DBManagerFactory.GetParameterSQL("@Original_Mahs", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Mahs", System.Data.DataRowVersion.Original, null); arrParamDelete[3] = DBManagerFactory.GetParameterSQL("@Original_Mamon", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Mamon", System.Data.DataRowVersion.Original, null); arrParamDelete[4] = DBManagerFactory.GetParameterSQL("@Original_Makt", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "Makt", System.Data.DataRowVersion.Original, null); success = idbManager.UpdateDataSet(dtsCTKTRA, CommandType.StoredProcedure, "spCTKTRAThem", "spCTKTRAUpdate", "spCTKTRAXoa", arrParamInsert, arrParamUpdate, arrParamDelete); } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ICTKTRA.UpdateSP(DtsCTKTRA dtsCTKTRA)" + e.Message); } finally { idbManager.Dispose(); } return success; } DataTable ICTKTRA.XemLOAIKTRA(byte hocky) { DataTable tbl = null; try { idbManager.CreateParameters(1); idbManager.AddParameters(0, "@Hocky", hocky, ParameterDirection.Input); idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spLOAIKTRAXemTheoHocky").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ICTKTRA.XemLOAIKTRA()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } DataTable ICTKTRA.XemDMLOP() { DataTable tbl = null; try { idbManager.Open(); tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "spDMLOPXem").Tables[0]; } catch (DatabaseExc e) { throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL); } catch (Exception e) { throw new BussinessExc("Bussiness. ICTKTRA.XemDMLOP()" + e.Message); } finally { idbManager.Dispose(); } return tbl; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/CTKTRAProcess.cs
C#
gpl2
8,068
using System; using System.Collections.Generic; using System.Text; namespace Bussiness.Exc { public class BussinessExc : Exception { public BussinessExc(string message) : base(message) { } private int errCodeSQL=0; private int errCodeUser=0; public int ErrCodeSQL { get { return errCodeSQL; } set { errCodeSQL = value; } } public int ErrCodeUser { get { return errCodeUser; } set { errCodeUser = value; } } public BussinessExc(string message,int errCodeSQL) : base(message) { this.errCodeSQL = errCodeSQL; } public BussinessExc(string message, int errCodeUser, int errCodeSQL) : base(message) { this.errCodeSQL = errCodeSQL; this.errCodeUser = errCodeUser; } } }
0871152qlhs
trunk/QLHS_Souce_Code/Bussiness/Exc/BussinessExc.cs
C#
gpl2
1,065
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QuaLyHocSinh { public partial class frmDMMONBaocao : Form { public frmDMMONBaocao() { InitializeComponent(); } } }
0871152qlhs
trunk/QLHS_Souce_Code/QuaLyHocSinh/frmDMMONBaocao.cs
C#
gpl2
355
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace QuaLyHocSinh { class ProcessError { public static void SaveErr(string pathFileName,string[] arrStrErr) { StreamWriter wr = new StreamWriter(pathFileName,true,Encoding.Unicode); wr.WriteLine("-----"+DateTime.Now.ToLongDateString()+" "+DateTime.Now.ToLongTimeString()+"-----"); for (int i = 0; i < arrStrErr.Length; i++) wr.WriteLine(arrStrErr[i]); wr.WriteLine(""); wr.Close(); } } }
0871152qlhs
trunk/QLHS_Souce_Code/QuaLyHocSinh/ProcessError.cs
C#
gpl2
624
using System; using System.Collections.Generic; using System.Windows.Forms; namespace QuaLyHocSinh { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } } }
0871152qlhs
trunk/QLHS_Souce_Code/QuaLyHocSinh/Program.cs
C#
gpl2
481
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("QuaLyHocSinh")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Heaven")] [assembly: AssemblyProduct("QuaLyHocSinh")] [assembly: AssemblyCopyright("Copyright © Heaven 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("208977e1-cfce-4276-a316-a16a1536da65")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0871152qlhs
trunk/QLHS_Souce_Code/QuaLyHocSinh/Properties/AssemblyInfo.cs
C#
gpl2
1,284
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; namespace UserControls { public partial class TienIchControls : UserControl { public TienIchControls() { InitializeComponent(); } public delegate void bttClick(object sender, EventArgs e); public bttClick btt_click1 = null; public bttClick btt_click3 = null; // // Ham va thuoc tinh // public bool CheckTieuDeBangHH { get { return xCheckBox1.Checked; } set { xCheckBox1.Checked = value; } } public bool CheckDieuKienThanhMN { get { return xCheckBox2.Checked; } set { xCheckBox2.Checked = value; } } public bool CheckTatThoiGianHH { get { return xCheckBox3.Checked; } set { xCheckBox3.Checked = value; } } public bool CheckTatCheDoTuDongHT { get { return xCheckBox4.Checked; } set { xCheckBox4.Checked = value; } } public bool CheckTatHinhNenThanhMN { get { return xCheckBox5.Checked; } set { xCheckBox5.Checked = value; } } public bool EnableGroupDangNhap { get { return xGroup5.Enabled; } set { xGroup5.Enabled = value; } } public bool EnableGroupHieuChinh { get { return xGroup7.Enabled; } set { xGroup7.Enabled = value; } } public string TxtUser { get { return xTextBox1.Text; } set { if (value == null) { value = ""; } xTextBox1.Text = value; } } public string TxtPass { get { return xTextBox2.Text; } set { if (value == null) { value = ""; } xTextBox2.Text = value; } } public string TxtUserHC { get { return xTextBox6.Text; } set { if (value == null) { value = ""; } xTextBox6.Text = value; } } public string TxtPassHC { get { return xTextBox7.Text; } set { if (value == null) { value = ""; } xTextBox7.Text = value; } } public void OpenThanhTieuDe(bool open) { if (open) xGroup1.Expand(); else xGroup1.Collapse(); } public void OpenDieuThanhMenu(bool open) { if (open) xGroup2.Expand(); else xGroup2.Collapse(); } public void OpenDieuMayTinh(bool open) { if (open) xGroup3.Expand(); else xGroup3.Collapse(); } public void OpenDieuLichBieu(bool open) { if (open) xGroup4.Expand(); else xGroup4.Collapse(); } public void OpenDanhNhap(bool open) { if (open) xGroup5.Expand(); else xGroup5.Collapse(); } public void OpenHieuChinh(bool open) { if (open) xGroup7.Expand(); else xGroup7.Collapse(); } public void Open(bool open) { if (!open) { xTabControl1.Width = 0; this.Width = 11; } else { xTabControl1.Width = 270; this.Width = 281; } } public void ChangeTab(int tabIndex) { if (tabIndex >= 0 && tabIndex < xTabControl1.TabCount) xTabControl1.SelectedIndex = tabIndex; else throw new ExcUser("tabIndex nam ngoai gioi han (ChangeTab)"); } // // Dieu Khien Su Kien // private void xButtonEx1_Click(object sender, EventArgs e) { if(btt_click1!=null) btt_click1(sender, e); } private void xButtonEx3_Click(object sender, EventArgs e) { if (btt_click3 != null) btt_click3(sender, e); } private void xPictureButton1_MouseDown(object sender, MouseEventArgs e) { if (this.Width == 281) this.Width = 11; else this.Width = 281; } private void TienIchControls_Load(object sender, EventArgs e) { xGroup2.Collapse(); xGroup4.Collapse(); xGroup7.Collapse(); xTabControl1.SelectedIndex = 1; Open(true); } private void xTreeView1_AfterSelect(object sender, TreeViewEventArgs e) { } private void xTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) xButtonEx1_Click(sender, e); } private void xTextBox2_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode==Keys.Enter) xButtonEx1_Click(sender, e); } } }
0871152qlhs
trunk/QLHS_Souce_Code/UserControls/TienIchControls.cs
C#
gpl2
6,016
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("UserControls")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Heaven")] [assembly: AssemblyProduct("UserControls")] [assembly: AssemblyCopyright("Copyright © Heaven 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("32fe0026-13e8-4ec9-969d-88c2d5fc93cd")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0871152qlhs
trunk/QLHS_Souce_Code/UserControls/Properties/AssemblyInfo.cs
C#
gpl2
1,407
using System; using System.Collections.Generic; using System.Text; namespace UserControls { public class ExcUser : Exception { public ExcUser(string message) : base(message) { } } }
0871152qlhs
trunk/QLHS_Souce_Code/UserControls/ExcUser.cs
C#
gpl2
245
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QUANLYNHASACH { public partial class frmQUANLYTAIKHOAN : Form { QUANLYNHASACH.User_BLL bllUser = new QUANLYNHASACH.User_BLL(); public frmQUANLYTAIKHOAN() { InitializeComponent(); } private void frmQUANLYTAIKHOAN_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'ds_quanlybansach.GROUPS' table. You can move, or remove it, as needed. this.gROUPSTableAdapter.Fill(this.ds_quanlybansach.GROUPS); GridUser.DataSource = bllUser.LayDanhSachUser(); } private void btnThem_Click(object sender, EventArgs e) { string idUsr = bllUser.CreateID() ; string idGroup = cbbQuyen.SelectedValue.ToString() ; string UserName=txtUser.Text; string Password=txtPassword.Text; string Hoten=txtHoten.Text; bllUser.ThemUser(idUsr, idGroup, UserName, Password, Hoten); GridUser.DataSource= bllUser.LayDanhSachUser(); } private void btnSua_Click(object sender, EventArgs e) { bool isCheck = false; for (int i = 0; i < this.GridUser.Rows.Count; i++) { if (this.GridUser.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.GridUser.Rows[i].Cells[0].Value; string idUser = this.GridUser.Rows[i].Cells[1].Value.ToString(); string idGroup = this.GridUser.Rows[i].Cells[2].Value.ToString(); string UserName = this.GridUser.Rows[i].Cells[3].Value.ToString(); string Password = this.GridUser.Rows[i].Cells[4].Value.ToString(); string HoTen = this.GridUser.Rows[i].Cells[5].Value.ToString(); if (isCheck == true) { bllUser.CapNhatUser(idUser,idGroup,UserName,Password,HoTen); } GridUser.DataSource= bllUser.LayDanhSachUser(); } } MessageBox.Show("Đã cập nhật danh sách user thành công", "Thông báo"); } private void btnXoa_Click(object sender, EventArgs e) { bool isCheck = false; for (int i = 0; i < this.GridUser.Rows.Count; i++) { if (this.GridUser.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.GridUser.Rows[i].Cells[0].Value; string idNXB = this.GridUser.Rows[i].Cells[1].Value.ToString(); if (isCheck == true) { bllUser.XoaUser(idNXB); } GridUser.DataSource = bllUser.LayDanhSachUser(); } } } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/frmQUANLYTAIKHOAN.cs
C#
art
3,190
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using QUANLYNHASACH.App_code.BLL; namespace QUANLYNHASACH { public partial class frmManHinhChinh : Form { private int childFormNumber = 0; public frmManHinhChinh() { InitializeComponent(); } private void ShowNewForm(object sender, EventArgs e) { Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = "Window " + childFormNumber++; childForm.Show(); } private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = openFileDialog.FileName; } } private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = saveFileDialog.FileName; } } private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } private void CutToolStripMenuItem_Click(object sender, EventArgs e) { } private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { } private void PasteToolStripMenuItem_Click(object sender, EventArgs e) { } private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade); } private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileVertical); } private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileHorizontal); } private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.ArrangeIcons); } private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Form childForm in MdiChildren) { childForm.Close(); } } private void bảngThamSốToolStripMenuItem_Click(object sender, EventArgs e) { } private void thoátToolStripMenuItem1_Click(object sender, EventArgs e) { Application.Exit(); } private void quảnLýThểLoạiToolStripMenuItem_Click(object sender, EventArgs e) { frmQUANLYTHELOAI theloai = new frmQUANLYTHELOAI(); theloai.MdiParent = this; theloai.Show(); } private void quảnLýNXBToolStripMenuItem_Click(object sender, EventArgs e) { frmQuanLyNXB nxb = new frmQuanLyNXB(); nxb.MdiParent = this; nxb.Show(); } private void thoátToolStripMenuItem_Click(object sender, EventArgs e) { frmQUANLYTAIKHOAN frmQLTK = new frmQUANLYTAIKHOAN(); frmQLTK.Show(); } private void quảnLýNhómToolStripMenuItem_Click(object sender, EventArgs e) { QuanlyGroup QLGroup = new QuanlyGroup(); QLGroup.Show(); } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/frmManHinhChinh.cs
C#
art
4,177
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("QUANLYNHASACH")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("tsd")] [assembly: AssemblyProduct("QUANLYNHASACH")] [assembly: AssemblyCopyright("Copyright © tsd 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("db1c49da-c525-4d94-9cf2-2a6e3fa50d5c")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/Properties/AssemblyInfo.cs
C#
art
1,280
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QUANLYNHASACH { public partial class frmSACH : Form { public frmSACH() { InitializeComponent(); } QUANLYNHASACH.App_code.BLL.SACH_BLL sach_bll = new QUANLYNHASACH.App_code.BLL.SACH_BLL(); private void frmSACH_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'ds_quanlybansach.NHAXUATBAN' table. You can move, or remove it, as needed. //this.nHAXUATBANTableAdapter.Fill(this.ds_quanlybansach.NHAXUATBAN); // TODO: This line of code loads data into the 'ds_quanlybansach.THELOAI' table. You can move, or remove it, as needed. //this.tHELOAITableAdapter.Fill(this.ds_quanlybansach.THELOAI); dtgSach.DataSource = sach_bll.LayChiTietSach(); } private void btnThem_Click(object sender, EventArgs e) { try { string idsach = "000" + txtID.Text; string idtheloai = cbTheLoai.SelectedValue.ToString(); string idnxb = cbNXB.SelectedValue.ToString(); string tensach = txtTenSach.Text; string tacgia = txtTacGia.Text; string dichgia = txtDichGia.Text; float kichthuoc = float.Parse(txtKichThuoc.Text); string hinhthuc = txtHinhThuc.Text; float trongluong = float.Parse(txtTrongLuong.Text); float giaban = float.Parse(txtGiaBan.Text); int SLTrongKho = int.Parse(txtSLTrongKho.Text); int sotrang = int.Parse(txtSoTrang.Text); sach_bll.ThemSach(idsach, idtheloai, idnxb, tensach, tacgia, dichgia, sotrang, kichthuoc, hinhthuc, trongluong, giaban, SLTrongKho); MessageBox.Show("Thành công!", "thông báo"); dtgSach.DataSource = sach_bll.LayChiTietSach(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void btnXoa_Click(object sender, EventArgs e) { try { bool isCheck = false; for (int i = 0; i < dtgSach.Rows.Count; i++) { if (this.dtgSach.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.dtgSach.Rows[i].Cells[0].Value; string idSach = this.dtgSach.Rows[i].Cells[1].Value.ToString(); int SLTrongKho = int.Parse(this.dtgSach.Rows[i].Cells[12].Value.ToString()); if (SLTrongKho == 0) { if (isCheck == true) { sach_bll.xoasach(idSach); } } else { MessageBox.Show("Số lượng còn trong kho >0, không thể xóa sách này", "Thông báo"); } } } MessageBox.Show("Oh yeah!", "thông báo"); dtgSach.DataSource = sach_bll.LayChiTietSach(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void btnSua_Click(object sender, EventArgs e) { try { bool isCheck = false; for (int i = 0; i < this.dtgSach.Rows.Count; i++) { if (this.dtgSach.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.dtgSach.Rows[i].Cells[0].Value; string idSach = this.dtgSach.Rows[i].Cells[1].Value.ToString(); string idTheLoai_new = this.dtgSach.Rows[i].Cells[2].Value.ToString(); string idNhaXuatBan_new = this.dtgSach.Rows[i].Cells[3].Value.ToString(); string TenSach_new = this.dtgSach.Rows[i].Cells[4].Value.ToString(); string TacGia_new = this.dtgSach.Rows[i].Cells[5].Value.ToString(); string DichGia_new = this.dtgSach.Rows[i].Cells[6].Value.ToString(); int SoTrang_new = int.Parse(this.dtgSach.Rows[i].Cells[7].Value.ToString()); float KichThuoc_new = float.Parse(this.dtgSach.Rows[i].Cells[8].Value.ToString()); string HinhThuc_new = this.dtgSach.Rows[i].Cells[9].Value.ToString(); float TrongLuong_new = float.Parse(this.dtgSach.Rows[i].Cells[10].Value.ToString()); float GiaBia_new = float.Parse(this.dtgSach.Rows[i].Cells[11].Value.ToString()); int SLTrongKho = int.Parse(this.dtgSach.Rows[i].Cells[12].Value.ToString()); if (isCheck == true) { sach_bll.suasach(idSach, idTheLoai_new, idNhaXuatBan_new, TenSach_new, TacGia_new, DichGia_new, SoTrang_new, KichThuoc_new, HinhThuc_new, TrongLuong_new, GiaBia_new, SLTrongKho); } } } MessageBox.Show("Thành công!", "thông báo"); this.dtgSach.DataSource = sach_bll.LayChiTietSach(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/frmSACH.cs
C#
art
6,021
using System; using System.Collections.Generic; using System.Windows.Forms; namespace QUANLYNHASACH { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmDangNhap()); } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/Program.cs
C#
art
486
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QUANLYNHASACH { public partial class frmDangNhap : Form { QUANLYNHASACH.App_code.BLL.DANGNHAP_BLL blldangnhap = new QUANLYNHASACH.App_code.BLL.DANGNHAP_BLL(); public frmDangNhap() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void btOK_Click(object sender, EventArgs e) { // bool user = blldangnhap.layusername(txtTK.Text); // bool pass = blldangnhap.laypassword(txtPass.Text); //if (user == true && pass == true) //{ // MessageBox.Show("DANG NHAP THANH CONG"); //} //else //{ // MessageBox.Show("DANH NHAP KHONG THANH CONG"); //} } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/frmDangNhap.cs
C#
art
1,155
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QUANLYNHASACH { public partial class frmQUANLYTHELOAI : Form { QUANLYNHASACH.App_code.BLL.THELOAI_BLL bllTheLoai = new QUANLYNHASACH.App_code.BLL.THELOAI_BLL(); public frmQUANLYTHELOAI() { InitializeComponent(); } private void frmQUANLYTHELOAI_Load(object sender, EventArgs e) { dtgTheLoai.DataSource = bllTheLoai.LayDanhSachTheLoai(); } private void btThem_Click(object sender, EventArgs e) { try { string idTheLoai = "000" + txtID.Text; string tentheloai = txtTheLoai.Text; bllTheLoai.ThemTheLoai(idTheLoai, tentheloai); MessageBox.Show("Thành công!", "thông báo"); dtgTheLoai.DataSource = bllTheLoai.LayDanhSachTheLoai(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void btXoa_Click(object sender, EventArgs e) { try { bool isCheck = false; for (int i = 0; i < dtgTheLoai.Rows.Count; i++) { if (dtgTheLoai.Rows[i].Cells[0].Value != null) { isCheck = (bool)dtgTheLoai.Rows[i].Cells[0].Value; string idTheLoai = dtgTheLoai.Rows[i].Cells[1].Value.ToString(); if (isCheck == true) { bllTheLoai.xoaTheLoai(idTheLoai); } } } MessageBox.Show("Oh yeah!", "thông báo"); dtgTheLoai.DataSource = bllTheLoai.LayDanhSachTheLoai(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void btSua_Click(object sender, EventArgs e) { try { bool isCheck = false; for (int i = 0; i < dtgTheLoai.Rows.Count; i++) { if (dtgTheLoai.Rows[i].Cells[0].Value != null) { isCheck = (bool)dtgTheLoai.Rows[i].Cells[0].Value; string idTheLoai = dtgTheLoai.Rows[i].Cells[1].Value.ToString(); string tentheloai = dtgTheLoai.Rows[i].Cells[2].Value.ToString(); if (isCheck == true) { bllTheLoai.suaTheLoai(idTheLoai, tentheloai); } } } MessageBox.Show("Thành công!", "thông báo"); dtgTheLoai.DataSource = bllTheLoai.LayDanhSachTheLoai(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/frmQUANLYTHELOAI.cs
C#
art
3,446
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using System.IO; namespace QUANLYNHASACH { class connection_string { public static String svName = "."; public static String dbName = "QUANLYNHASACH"; public static bool intergratedMode = false; public static String userName = "sa"; public static String pwd = "123"; public static string _connPath = "config.txt"; //thuộc tính SqlConnection sqlconn; #region khởi tạo chuỗi kết nối public connection_string(string svrName, string dbName, bool intergratedMode, string usrName, string pwd) { string connStr; if (intergratedMode == true) { //đăng nhập sql server sử dụng windows authentication mode connStr = "server" + svrName + "; database =" + dbName + "; IntergratedSecurity = True"; } else { //đăng nhập sql server sử dụng sql server authentication mode connStr = "server=" + svrName + "; uid=" + usrName + "; pwd=" + pwd + " ;database=" + dbName; } //thiết lập chuỗi kết nối sqlconn = new SqlConnection(connStr); } #endregion #region Thực thi câu truy vấn sql trả về bảng public DataTable Execute(string strQuery) { SqlDataAdapter da = new SqlDataAdapter(strQuery, sqlconn); DataSet ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; } #endregion #region Thực hiện câu truy vấn ko trả về bảng public void ExecuteNonQuery(string strquery) { //thực hiện câu truy vấn SqlCommand sqlcom = new SqlCommand(strquery, sqlconn); sqlconn.Open(); //Mở kết nối sqlcom.ExecuteNonQuery(); //Thực hiện câu lệnh truy vấn đã cung cấp ở trên sqlconn.Close(); //Đóng kết nối } #endregion #region ExecuteScalar public int ExecuteScalar(string strquery) { Int32 count = 0; //SqlCommand là đối tượng chuyên đảm nhận việc thực hiện các câu lệnh truy vấn SqlCommand sqlcom = new SqlCommand(strquery, sqlconn); sqlconn.Open(); count = (Int32)sqlcom.ExecuteScalar(); //Thực hiện câu lệnh truy vấn đã cung cấp ở trên sqlconn.Close(); //Đóng kết nối return (int)count; } #endregion } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/connection.cs
C#
art
2,848
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace QUANLYNHASACH { public partial class QuanlyGroup : Form { QUANLYNHASACH.App_code.BLL.Group_BLL bllGroup = new QUANLYNHASACH.App_code.BLL.Group_BLL(); public QuanlyGroup() { InitializeComponent(); } private void btnThem_Click(object sender, EventArgs e) { string idGroup = txtIdGroup.Text; string Capbac = txtCapBac.Text; bllGroup.ThemGroup(idGroup, Capbac); GridGroup.DataSource = bllGroup.LayDanhSachGroup(); } private void btnSua_Click(object sender, EventArgs e) { bool isCheck = false; for (int i = 0; i < this.GridGroup.Rows.Count; i++) { if (this.GridGroup.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.GridGroup.Rows[i].Cells[0].Value; string idGroup = this.GridGroup.Rows[i].Cells[1].Value.ToString(); string Capbac = this.GridGroup.Rows[i].Cells[2].Value.ToString(); if (isCheck == true) { bllGroup.CapNhatGroup(idGroup, Capbac); } } } MessageBox.Show("Đã cập nhật danh sách group thành công", "Thông báo"); } private void btnXoa_Click(object sender, EventArgs e) { bool isCheck = false; for (int i = 0; i < this.GridGroup.Rows.Count; i++) { if (this.GridGroup.Rows[i].Cells[0].Value != null) { isCheck = (bool)this.GridGroup.Rows[i].Cells[0].Value; string idGroup = this.GridGroup.Rows[i].Cells[1].Value.ToString(); if (isCheck == true) { bllGroup.XoaGroup(idGroup); } GridGroup.DataSource = bllGroup.LayDanhSachGroup(); } } } private void QuanlyGroup_Load(object sender, EventArgs e) { GridGroup.DataSource = bllGroup.LayDanhSachGroup(); } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/QuanlyGroup.cs
C#
art
2,491
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace QUANLYNHASACH { class connect { public static string _connPath = "config.txt"; private static string _connStr; private void GhiChuoiKetNoi() { _connStr = "Data Source=.;Initial Catalog= QUANLYNHASACH;Integrated Security=True;Pooling=False"; File.WriteAllText(_connPath, _connStr); } public static string GetChuoiKetNoi() { return File.ReadAllText(_connPath); } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/connect.cs
C#
art
603
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Data.SqlClient; namespace QUANLYNHASACH { public partial class quanlycosodulieu : Form { public static string _connPath = "config.txt"; private static string _connStr; public quanlycosodulieu() { InitializeComponent(); } private void btnThuKetNoi_Click(object sender, EventArgs e) { try { GhiChuoiKetNoi(); SqlConnection conn = new SqlConnection(GetChuoiKetNoi()); conn.Open(); if (conn.State == ConnectionState.Open) { MessageBox.Show("Kết nối cơ sở dữ liệu thành công", "Thông báo"); } else if (conn.State == ConnectionState.Broken) { MessageBox.Show("Không thể kết nối đến cơ sở dữ liệu", "Thống báo"); } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void GhiChuoiKetNoi() { if (chckWindows.Checked == true) { txtUser.Enabled = false; txtPass.Enabled = false; _connStr = "Data Source=" + txtServer.Text + ";Initial Catalog=" + txtDatabase.Text + ";Integrated Security=True;Pooling=False"; } else { txtUser.Enabled = true; txtPass.Enabled = true; _connStr = "Data Source=" + txtServer.Text + ";Initial Catalog=" + txtDatabase.Text + ";User ID=" + txtUser.Text + ";Password=" + txtPass.Text; } File.WriteAllText(_connPath, _connStr); } public static string GetChuoiKetNoi() { return File.ReadAllText(_connPath); } private void chckWindows_CheckedChanged(object sender, EventArgs e) { if (chckWindows.Checked) { txtUser.Enabled = false; txtPass.Enabled = false; } else { txtUser.Enabled = true; txtPass.Enabled = true; } } private void txtServer_TextChanged(object sender, EventArgs e) { } private void btnThuKetNoi_Click_1(object sender, EventArgs e) { try { GhiChuoiKetNoi(); SqlConnection conn = new SqlConnection(GetChuoiKetNoi()); conn.Open(); if (conn.State == ConnectionState.Open) { if (MessageBox.Show("Kết nối cơ sở dữ liệu thành công", "Thông báo") == DialogResult.OK) { frmManHinhChinh main = new frmManHinhChinh(); main.Show(); } } else if (conn.State == ConnectionState.Broken) { MessageBox.Show("Không thể kết nối đến cơ sở dữ liệu", "Thống báo"); } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Thông báo lỗi"); } } private void btnOK_Click_1(object sender, EventArgs e) { this.Close(); } } }
06th1d-12-quanlynhasach
trunk/QUANLYNHASACH/QUANLYNHASACH/quanlycosodulieu.cs
C#
art
3,826