//function to check if Mobile exist or not public Boolean IsMobile_Exist(string mobile) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Mobile", SqlDbType.VarChar, 50); param[0].Value = mobile; dataBaseHelperL.Open(); DataTable Dt1 = new DataTable(); Dt1 = dataBaseHelperL.SelectData("SP_IsMobile_ExistInAdmin", param); DataTable Dt2 = new DataTable(); Dt2 = dataBaseHelperL.SelectData("SP_IsMobile_ExistInBidder", param); DataTable Dt3 = new DataTable(); Dt3 = dataBaseHelperL.SelectData("SP_IsMobile_ExistInSeller", param); if (Dt1.Rows.Count > 0 || Dt2.Rows.Count > 0 || Dt3.Rows.Count > 0) { dataBaseHelperL.Close(); return(true); } else { dataBaseHelperL.Close(); return(false); } }
private void button7_Click(object sender, EventArgs e) { // Get Select Session ID int Session_Id = Convert.ToInt32(dgvSubscribedSession.CurrentRow.Cells[0].Value.ToString()); //Check Session Contaion Item Or Not DataTable Dt1 = new DataTable(); //Database Instance DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Session_Id", SqlDbType.Int); param[0].Value = Session_Id; dataBaseHelperL.Open(); Dt1 = dataBaseHelperL.SelectData("SP_ChekSessionNotContainItem", param); dataBaseHelperL.Close(); //Session Not Contain Item if (Dt1.Rows.Count > 0) { MessageBox.Show("Please Wait No Item Added !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Session Contain Item else { FORM_VIEW_SUB_SESSION_DETAILS formViewSubSess = new FORM_VIEW_SUB_SESSION_DETAILS(Session_Id); formViewSubSess.ShowDialog(); this.dgvSubscribedSession.DataSource = admin.View_Sessions("", 2); this.dgvStartedSsesions.DataSource = admin.View_Sessions("", 3); } }
private void btnAddItem_Click(object sender, EventArgs e) { //Seller Id int seller_id = _Seller.getID(); //Selected Session Id int Session_ID = Convert.ToInt32(dgvMySession.CurrentRow.Cells[0].Value.ToString()); //Check The Session Contain Item Or Not DataTable Dt1 = new DataTable(); //Database Instance DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Session_Id", SqlDbType.Int); param[0].Value = Session_ID; dataBaseHelperL.Open(); Dt1 = dataBaseHelperL.SelectData("SP_ChekSessionNotContainItem", param); dataBaseHelperL.Close(); //Session Not Contain Item if (Dt1.Rows.Count > 0) { FORM_ADD_ITEM_SELLER form_add_Item = new FORM_ADD_ITEM_SELLER(seller_id, Session_ID); form_add_Item.ShowDialog(); } //Session Contain Item else { MessageBox.Show("This Session Contain an Item !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//function to check if username exist or not in Bidder public Boolean IsUserName_ExistInBidder(string username) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@UserName", SqlDbType.VarChar, 50); param[0].Value = username; dataBaseHelperL.Open(); DataTable Dt2 = new DataTable(); Dt2 = dataBaseHelperL.SelectData("SP_IsUserName_ExistInBidder", param); if (Dt2.Rows.Count > 0) { dataBaseHelperL.Close(); return(true); } else { dataBaseHelperL.Close(); return(false); } }
//Function Edit profile public void EditProfile(User user) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[6]; param[0] = new SqlParameter("@UserName", SqlDbType.VarChar, 50); param[0].Value = user.getUserName();; param[1] = new SqlParameter("@Password", SqlDbType.VarChar, 50); param[1].Value = user.getPassword(); param[2] = new SqlParameter("@Email", SqlDbType.VarChar, 70); param[2].Value = user.getEmail(); param[3] = new SqlParameter("@Address", SqlDbType.VarChar, 100); param[3].Value = user.getAddress(); param[4] = new SqlParameter("@Mobile", SqlDbType.VarChar, 50); param[4].Value = user.getMobile(); param[5] = new SqlParameter("@UserType", SqlDbType.VarChar, 50); param[5].Value = user.getUserType(); dataBaseHelperL.Open(); dataBaseHelperL.SelectData("SP_UPDATE_PROFILE", param); dataBaseHelperL.Close(); }
//Function To Check Session Name Existence public Boolean IsSessionNameExist(string name) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Name", SqlDbType.VarChar, 50); param[0].Value = name; dataBaseHelperL.Open(); DataTable Dt1 = new DataTable(); Dt1 = dataBaseHelperL.SelectData("SP_IS_SessionNameExist", param); if (Dt1.Rows.Count > 0) { dataBaseHelperL.Close(); return(true); } else { dataBaseHelperL.Close(); return(false); } }
//View Report public DataTable view_Report() { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_GetReport", null); dataBaseHelperL.Close(); return(Dt); }
//Function to View Notify public DataTable view_NotificationStartedSessions() { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_View_Started_Session_Bidder", null); dataBaseHelperL.Close(); return(Dt); }
//Function To View Notifiction With Result Winner Or not public DataTable view_NotificationWithSessionsResult() { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_Result", null); dataBaseHelperL.Close(); return(Dt); }
//Function to View Available Session public DataTable ViewAvailableSessions(string Search) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Criterion", SqlDbType.VarChar, 50); param[0].Value = Search; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_ViewAvailableSessionsSeller", param); dataBaseHelperL.Close(); return(Dt); }
//function to Check Bid public DataTable checkLastBidderOnCurrentSession(int SessionId) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Session_Id", SqlDbType.Int); param[0].Value = SessionId; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_LastBidder", param); dataBaseHelperL.Close(); return(Dt); }
//Function To View Notifiction With Winner public DataTable view_NotificationWithWinner(int bidder_ID) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@bidderID", SqlDbType.Int); param[0].Value = bidder_ID; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_ResultWinner", param); dataBaseHelperL.Close(); return(Dt); }
//Function To View Session Details public DataTable view_Session_Deatails(int Session_Id) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@sessionID", SqlDbType.Int); param[0].Value = Session_Id; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_View_Session_Details_Bidder", param); dataBaseHelperL.Close(); return(Dt); }
//Function to List All Users public DataTable view_Users(string Criterion, string UserType) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@Criterion", SqlDbType.VarChar, 50); param[0].Value = Criterion; param[1] = new SqlParameter("@UserType", SqlDbType.VarChar, 50); param[1].Value = UserType; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_ViewUsers", param); dataBaseHelperL.Close(); return(Dt); }
//Function To Retrieve All Sessions public DataTable View_Sessions(string search, int status) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@Criterion", SqlDbType.VarChar, 50); param[0].Value = search; param[1] = new SqlParameter("@Status", SqlDbType.Int); param[1].Value = status; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_ViewSessionAdmin", param); dataBaseHelperL.Close(); return(Dt); }
//Function To view Subscribed Sessions of the Seller public DataTable ViewMySessions(string Search, int Seller_ID) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@Criterion", SqlDbType.VarChar, 50); param[0].Value = Search; param[1] = new SqlParameter("@Seller_ID", SqlDbType.Int); param[1].Value = Seller_ID; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_View_Subscribed_Session_Seller", param); dataBaseHelperL.Close(); return(Dt); }
//Function to Login public DataTable LOGIN(string UserName, string Password, string UserType) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@UserName", SqlDbType.VarChar, 50); param[0].Value = UserName; param[1] = new SqlParameter("@Password", SqlDbType.VarChar, 50); param[1].Value = Password; param[2] = new SqlParameter("@UserType", SqlDbType.VarChar, 50); param[2].Value = UserType; dataBaseHelperL.Open(); DataTable Dt = new DataTable(); Dt = dataBaseHelperL.SelectData("SP_Login", param); dataBaseHelperL.Close(); return(Dt); }
//Function Generate Invoice public Invoice GenerateInvoice(int SessionId) { DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; DataTable Dt = new DataTable(); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@sessionID", SqlDbType.Int); param[0].Value = SessionId; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_GetInvoice", param); dataBaseHelperL.Close(); int id = int.Parse(Dt.Rows[0]["Inovice Number"].ToString()); string seller = Dt.Rows[0]["Seller Name"].ToString(); string bidder = Dt.Rows[0]["Bidder Name"].ToString(); string itemName = Dt.Rows[0]["Item Name"].ToString(); string itemDes = Dt.Rows[0]["Item Description"].ToString(); float price = float.Parse(Dt.Rows[0]["Price"].ToString()); DateTime date = Convert.ToDateTime(Dt.Rows[0]["Date"].ToString()); Invoice invoice = new Invoice(); invoice.set_ID(id); invoice.set_Seller(seller); invoice.set_Buyer(bidder); invoice.set_ItemName(itemName); invoice.set_ItemDescription(itemDes); invoice.set_price(price); invoice.set_Date(date); return(invoice); }
private void btnAddItem_Click(object sender, EventArgs e) { //Validate Data if (txtItemName.Text == string.Empty || txtItemDescription.Text == string.Empty || txtItemName.Text == string.Empty || picItemPicture.Image == null) { MessageBox.Show("Please Complete Data !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtItemName.Text.Count() >= 50 || txtInitailPrice.Text.Count() >= 50) { MessageBox.Show("Please Inter Vaild Data !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //check Name Correctness bool checkNameCorrectness; checkNameCorrectness = validation.IsAddres(txtItemName.Text); if (checkNameCorrectness == false) { MessageBox.Show("Please enter a correct Name !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //check Description Correctness bool checkDescriptionCorrectness; checkDescriptionCorrectness = validation.IsAddres(txtItemDescription.Text); if (checkDescriptionCorrectness == false) { MessageBox.Show("Please enter a correct Description !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Check price Correctness bool checkPrice; checkPrice = (validation.IsPrice(txtInitailPrice.Text)); if (checkPrice == false) { MessageBox.Show("Please enter A Correct price ! ", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ///////////////////////////////////////////////////////////////////// //Get Item Id From Data Base First Select Max Id then Add 1 to Id int ItemId; DataTable Dt = new DataTable(); //Database Instance DataAccessLayer.DataBaseHelper dataBaseHelperL = DataAccessLayer.DataBaseHelper.GetDataBaseHelperInstance; dataBaseHelperL.Open(); Dt = dataBaseHelperL.SelectData("SP_SelectMaxItemId", null); dataBaseHelperL.Close(); if (Dt.Rows[0]["ID"].ToString() == string.Empty) { ItemId = 1; } else { ItemId = Convert.ToInt32(Dt.Rows[0]["ID"].ToString()) + 1; } //Save picture MemoryStream ms = new MemoryStream(); picItemPicture.Image.Save(ms, picItemPicture.Image.RawFormat); byte[] byteImage = ms.ToArray(); //Create Item Object Item _item = new Item(ItemId, txtItemName.Text, txtItemDescription.Text, byteImage, Convert.ToSingle(txtInitailPrice.Text), Seller_ID); //seller Object to add item Seller seller = new Seller(); seller.add_Item(_item, Session_Id); MessageBox.Show("Item Added Successfully", "Added", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }