Esempio n. 1
0
        public static Int64 getCustIDwrtPhone(string phone)
        {
            Int64 custID = 0;

            try
            {
                SqlCommand cmd = new SqlCommand("st_getCustIdWRTPhone", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@phone", phone);
                MainClass.con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        custID   = Convert.ToInt64(dr["CustomerID"].ToString());
                        CUSTOMER = dr["Name"].ToString();
                        ADDRESS  = dr["Address"].ToString();
                    }
                }
                else
                {
                    custID   = 0;
                    CUSTOMER = "";
                    ADDRESS  = "";
                }
                MainClass.con.Close();
            }
            catch (Exception ex)
            {
                MainClass.con.Close();
                MainClass.showMessage(ex.Message, "error");
            }
            return(custID);
        }
        public static void updateCustomer(Int64 cid, string name, string phone, string address)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_updateCustomer", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@phone", phone);
                cmd.Parameters.AddWithValue("@address", address);
                cmd.Parameters.AddWithValue("@cID", cid);

                MainClass.con.Open();
                int res = cmd.ExecuteNonQuery();
                MainClass.con.Close();
                if (res > 0)
                {
                    MainClass.showMessage(name + " updated successfully into the system.", "success");
                }
            }
            catch (Exception)
            {
                MainClass.con.Close();
                MainClass.showMessage("Unable to update customer.\nContact technical support", "error");
            }
        }
Esempio n. 3
0
 public static void getUsers(DataGridView gv, DataGridViewColumn userIDgv, DataGridViewColumn nameGV, DataGridViewColumn usernameGV, DataGridViewColumn passGV, DataGridViewColumn phoneGV, DataGridViewColumn addressGV, DataGridViewColumn roleIDGV, DataGridViewColumn roleGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getUsers", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();;
         da.Fill(dt);
         userIDgv.DataPropertyName   = dt.Columns["User ID"].ToString();
         nameGV.DataPropertyName     = dt.Columns["User"].ToString();
         usernameGV.DataPropertyName = dt.Columns["Username"].ToString();
         passGV.DataPropertyName     = dt.Columns["Password"].ToString();
         phoneGV.DataPropertyName    = dt.Columns["Phone"].ToString();
         addressGV.DataPropertyName  = dt.Columns["Address"].ToString();
         roleIDGV.DataPropertyName   = dt.Columns["Role ID"].ToString();
         roleGV.DataPropertyName     = dt.Columns["Role"].ToString();
         gv.DataSource = dt;
         MainClass.sno(gv, "snoGV");
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, " error");
     }
 }
 public static void updateMenuItem(int menuID, string name, float price, int catID, int status)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_updateMenuItem", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@name", name);
         cmd.Parameters.AddWithValue("@price", price);
         cmd.Parameters.AddWithValue("@catID", catID);
         cmd.Parameters.AddWithValue("@status", status);
         cmd.Parameters.AddWithValue("@menuID", menuID);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage("Menu Item '" + name + "' updated successfully into the system.", "success");
         }
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.showMessage("Unable to update the Menu Item.\nContact technical support", "error");
     }
 }
        public static void updateUsers(int userID, string name, string uname, string pass, string address, string phone, Int16 roleID)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_updateUsers", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@username", uname);
                cmd.Parameters.AddWithValue("@password", pass);
                cmd.Parameters.AddWithValue("@address", address);
                cmd.Parameters.AddWithValue("@phone", phone);
                cmd.Parameters.AddWithValue("@roleID", roleID);
                cmd.Parameters.AddWithValue("@userID", userID);

                MainClass.con.Open();
                int res = cmd.ExecuteNonQuery();
                MainClass.con.Close();
                if (res > 0)
                {
                    MainClass.showMessage(name + " updated successfully into the system", "success");
                }
            }
            catch (Exception ex)
            {
                MainClass.con.Close();
                MainClass.showMessage("Unable to update the user.\nContact technical support", "error");
            }
        }
Esempio n. 6
0
 public static void insertOrder(DateTime date, Int64 custID, Int16 orderType, Int16 floorID, Int16 tableID, float tamount, float amountPaid, float amtReturned, Int16 status)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_insertOrder", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@date", date);
         cmd.Parameters.AddWithValue("@custID", custID);
         cmd.Parameters.AddWithValue("@orderType", orderType);
         cmd.Parameters.AddWithValue("@floorID", floorID);
         cmd.Parameters.AddWithValue("@tableID", tableID);
         cmd.Parameters.AddWithValue("@tAmount", tamount);
         cmd.Parameters.AddWithValue("@amtPaid", amountPaid);
         cmd.Parameters.AddWithValue("@amtReturned", amtReturned);
         cmd.Parameters.AddWithValue("@status", status);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage("Order placed successfully.", "success");
         }
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.showMessage(ex.Message, "error");
     }
 }
Esempio n. 7
0
 public static void deleteData(string procedure, string param, int value1 = 0, Int64 value2 = 0)
 {
     try
     {
         SqlCommand cmd = new SqlCommand(procedure, MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         if (value1 != 0)
         {
             cmd.Parameters.AddWithValue(param, value1);
         }
         if (value2 != 0)
         {
             cmd.Parameters.AddWithValue(param, value2);
         }
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage(" Data deleted successfully from the system", "success");
         }
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.showMessage(ex.Message, "error");
     }
 }
Esempio n. 8
0
 public static void loadReport(ReportDocument rd, CrystalReportViewer crv, Int16 status, string phone = null, int?tableID = null)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getOrderReport", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         if (phone == null)
         {
             cmd.Parameters.AddWithValue("@tableID", tableID);
             cmd.Parameters.AddWithValue("@status", status);
             cmd.Parameters.AddWithValue("@phone", DBNull.Value);
         }
         else
         {
             cmd.Parameters.AddWithValue("@phone", phone);
             cmd.Parameters.AddWithValue("@status", status);
             cmd.Parameters.AddWithValue("@tableID", DBNull.Value);
         }
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         rd.Load(Application.StartupPath + "\\Reports\\billReport.rpt");
         rd.SetDataSource(dt);
         crv.ReportSource = rd;
         crv.RefreshReport();
     }
     catch (Exception ex)
     {
         if (rd != null)
         {
             rd.Close();
         }
         MainClass.showMessage(ex.Message, "error");
     }
 }
 public override void savebtn_Click(object sender, EventArgs e)
 {
     if (rolesTxt.Text == "")
     {
         rolesErrorLabel.Visible = true;
     }
     else
     {
         rolesErrorLabel.Visible = false;
     }
     if (rolesErrorLabel.Visible)
     {
         MainClass.showMessage("Fields with * are mandatory", "Error");
     }
     else
     {
         if (edit == 0)
         {
             insertion.insertRole(rolesTxt.Text);
             MainClass.resetDisable(leftpanel);
             RetrivalData.getRoles(dataGridView1, RoleIDGV, RoleGV);
         }
         else if (edit == 1)
         {
             Updates.updateRole(rolesTxt.Text, roleID);
             MainClass.resetDisable(leftpanel);
             RetrivalData.getRoles(dataGridView1, RoleIDGV, RoleGV);
         }
     }
 }
Esempio n. 10
0
 private void itemDD_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (itemDD.SelectedIndex != -1)
     {
         try
         {
             itemEL.Visible = false;
             SqlCommand cmd = new SqlCommand("st_getPriceWRTitem", MainClass.con);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@mid", Convert.ToInt32(itemDD.SelectedValue.ToString()));
             MainClass.con.Open();
             priceTxt.Text = Math.Round(Convert.ToDouble(cmd.ExecuteScalar().ToString()), 0).ToString();
             MainClass.con.Close();
             DataRowView drv = itemDD.SelectedItem as DataRowView;
             RetrivalData.loadCategoryWRTItem(drv["Menu Name"].ToString());
         }
         catch (Exception ex)
         {
             MainClass.showMessage(ex.Message, "error");
         }
     }
     else
     {
         itemEL.Visible = true;
         priceTxt.Text  = "";
     }
 }
Esempio n. 11
0
 private void phoneTxt_Leave(object sender, EventArgs e)
 {
     try
     {
         if (phoneTxt.Text != "")
         {
             RetrivalData.getOrderBill(phoneTxt.Text, dataGridView1, ItemGV, QuantGV, amountGV, orderIDGV, totalAmountGV);
             BillLabel.Text  = Math.Round(Convert.ToDouble(dataGridView1.Rows[0].Cells["totalAmountGV"].Value.ToString()), 0).ToString();
             orderidTxt.Text = dataGridView1.Rows[0].Cells["orderIDGV"].Value.ToString();
         }
     }
     catch (Exception)
     {
         MainClass.showMessage("No order found", "error");
     }
 }
Esempio n. 12
0
 private void phonetxt_Leave(object sender, EventArgs e)
 {
     if (phonetxt.Text != "")
     {
         PhoneEL.Visible = false;
         custID          = RetrivalData.getCustIDwrtPhone(phonetxt.Text);
         if (custID == 0)
         {
             customersWindow cw = new customersWindow();
             MainClass.showWindow(cw, this, MDI.ActiveForm);
         }
         else
         {
             MainClass.showMessage(RetrivalData.CUSTOMER + "\n" + RetrivalData.ADDRESS + "\n", "success");
         }
     }
 }
Esempio n. 13
0
        private void insertOrderDetails()
        {
            Int64 orderID = RetrivalData.lastOrderID();
            int   count   = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                count += insertion.insertOrderDetails(orderID, Convert.ToInt32(row.Cells["itemIDGV"].Value.ToString()), Convert.ToInt16(row.Cells["QuantityGV"].Value.ToString()));
            }
            if (count > 0)
            {
            }
            else
            {
                MainClass.showMessage("An Error Occured", "error");
            }
        }
Esempio n. 14
0
 public static void getPendingOrders(DataGridView gv, DataGridViewColumn orderIDGV, DataGridViewColumn statusGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getOrders", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         orderIDGV.DataPropertyName = dt.Columns["OrderID"].ToString();
         statusGV.DataPropertyName  = dt.Columns["Status"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, "error");
     }
 }
Esempio n. 15
0
 public static void getCategory(DataGridView gv, DataGridViewColumn catIDGV, DataGridViewColumn catGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getCategories", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();;
         da.Fill(dt);
         catIDGV.DataPropertyName = dt.Columns["ID"].ToString();
         catGV.DataPropertyName   = dt.Columns["Category"].ToString();
         gv.DataSource            = dt;
         MainClass.sno(gv, "snoGV");
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, " error");
     }
 }
Esempio n. 16
0
 public static void getPendingOrderdetails(Int64 orderid, DataGridView gv, DataGridViewColumn prodGV, DataGridViewColumn quantityGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getOrderDetails", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@orderID", orderid);
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         prodGV.DataPropertyName     = dt.Columns["Item"].ToString();
         quantityGV.DataPropertyName = dt.Columns["Quantity"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, "error");
     }
 }
Esempio n. 17
0
        public static bool ValidUser(string user, string pass)
        {
            bool status = false;

            try
            {
                SqlCommand cmd = new SqlCommand("st_getUserAuth", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@user", user);
                cmd.Parameters.AddWithValue("@pass", pass);
                MainClass.con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        if (user == dr["Username"].ToString() && pass == dr["Password"].ToString())
                        {
                            USER   = dr["User"].ToString();
                            ROLE   = dr["Role"].ToString();
                            status = true;
                        }
                        else
                        {
                            MainClass.showMessage("Invalid username or password.", "error");
                            status = false;
                        }
                    }
                }
                else
                {
                    MainClass.showMessage("Invalid username or password.", "error");
                    status = false;
                }
                MainClass.con.Close();
            }
            catch (Exception ex)
            {
                MainClass.showMessage(ex.Message, "error");
            }
            return(status);
        }
Esempio n. 18
0
 public static void insertCategory(string name)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_insertCategory", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@name", name);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage("Category " + name + " added successfully into the system.", "success");
         }
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.showMessage("Unable to save the Category.\nThe table may already exist.\nContact technical support", "error");
     }
 }
Esempio n. 19
0
        public static int insertOrderDetails(Int64 orderID, int proID, Int16 quantity)
        {
            int res = 0;

            try
            {
                SqlCommand cmd = new SqlCommand("st_insertOrderDetails", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@orderID", orderID);
                cmd.Parameters.AddWithValue("@proID", proID);
                cmd.Parameters.AddWithValue("@quantity", quantity);
                MainClass.con.Open();
                res = cmd.ExecuteNonQuery();
                MainClass.con.Close();
            }
            catch (Exception)
            {
                MainClass.con.Close();
                MainClass.showMessage("Unable to save the Menu Item.\nThe table may already exist.\nContact technical support", "error");
            }
            return(res);
        }
Esempio n. 20
0
 public static void getTables(DataGridView gv, DataGridViewColumn floorIDGV, DataGridViewColumn floornameGV, DataGridViewColumn tableNameGV, DataGridViewColumn tableIDGV, DataGridViewColumn chairsGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getTables", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();;
         da.Fill(dt);
         floorIDGV.DataPropertyName   = dt.Columns["Floor ID"].ToString();
         floornameGV.DataPropertyName = dt.Columns["Floor"].ToString();
         tableIDGV.DataPropertyName   = dt.Columns["Table ID"].ToString();
         chairsGV.DataPropertyName    = dt.Columns["Chairs"].ToString();
         tableNameGV.DataPropertyName = dt.Columns["Table Number"].ToString();
         gv.DataSource = dt;
         MainClass.sno(gv, "snoGV");
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, " error");
     }
 }
        public static int updateOrder(Int64 orderID, float amountPaid, float amtReturned, Int16 status)
        {
            int res = 0;

            try
            {
                SqlCommand cmd = new SqlCommand("st_updateOrder", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@amtPaid", amountPaid);
                cmd.Parameters.AddWithValue("@amtReturned", amtReturned);
                cmd.Parameters.AddWithValue("@status", status);
                cmd.Parameters.AddWithValue("@orderID", orderID);
                MainClass.con.Open();
                res = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                MainClass.con.Close();
                MainClass.showMessage("Unable to save the Order.", "error");
            }
            return(res);
        }
Esempio n. 22
0
 public static void getOrderBill(int tableID, DataGridView gv, DataGridViewColumn itemGV, DataGridViewColumn quantGV, DataGridViewColumn amountGV, DataGridViewColumn orderID, DataGridViewColumn totalAmountGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getOrderSDetailsWRTtables", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tableId", tableID);
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         itemGV.DataPropertyName        = dt.Columns["Item"].ToString();
         quantGV.DataPropertyName       = dt.Columns["Quantity"].ToString();
         amountGV.DataPropertyName      = dt.Columns["Price"].ToString();
         orderID.DataPropertyName       = dt.Columns["ID"].ToString();
         totalAmountGV.DataPropertyName = dt.Columns["Toatl Amount"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception ex)
     {
         MainClass.showMessage(ex.Message, "error");
     }
 }
 public static void updateCategory(string name, int catID)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_updateCategory", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@name", name);
         cmd.Parameters.AddWithValue("@id", catID);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage(name + " updated successfully into the system", "success");
         }
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.showMessage(ex.Message, "Error");
     }
 }
 public static void updateOrderStatus(Int64 orderID, Int16 status)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_updateOrderStatus", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@orderID", orderID);
         cmd.Parameters.AddWithValue("@status", status);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage("Order status updated.", "success");
         }
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.showMessage("Unable to update ordder status.", "error");
     }
 }
 public static void updateFloors(Int16 floorID, string name, Int16 number)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_updateFloors", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@floor", name);
         cmd.Parameters.AddWithValue("@floorNumber", number);
         cmd.Parameters.AddWithValue("@floorID", floorID);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage(name + " added successfully into the system.", "success");
         }
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.showMessage("Unable to updated floor.\nContact technical support", "error");
     }
 }
Esempio n. 26
0
 public static void insertTables(int tableNumber, Int16 chairs, Int16 floorID)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_insertTables", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tableNumber", tableNumber);
         cmd.Parameters.AddWithValue("@chairs", chairs);
         cmd.Parameters.AddWithValue("@floorID", floorID);
         MainClass.con.Open();
         int res = cmd.ExecuteNonQuery();
         MainClass.con.Close();
         if (res > 0)
         {
             MainClass.showMessage(tableNumber + " added successfully into the system.", "success");
         }
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.showMessage("Unable to save table.\nThe table may already exist.\nContact technical support", "error");
     }
 }
Esempio n. 27
0
        private void savebtn_Click(object sender, EventArgs e)
        {
            if (iscb.Checked)
            {
                if (serverTxt.Text == "")
                {
                    serverErrorLabel.Visible = true;
                }
                else
                {
                    serverErrorLabel.Visible = false;
                }

                if (databaseTxt.Text == "")
                {
                    DbErrorLabel.Visible = true;
                }
                else
                {
                    DbErrorLabel.Visible = false;
                }


                if (serverErrorLabel.Visible || DbErrorLabel.Visible)
                {
                    MainClass.showMessage("Fields with * are mandatory.", "error");
                }
                else
                {
                    connection = "Data Source=" + serverTxt.Text +
                                 ";Initial Catalog=" + databaseTxt.Text +
                                 ";Integrated Security=true;MultipleActiveResultSets=true";
                    saveConnection();
                    DialogResult dr = MessageBox.Show("Settings saved succesfully.");
                    if (dr == DialogResult.OK)
                    {
                        LoginScreen ls = new LoginScreen();
                        MainClass.showWindow(ls, this, MDI.ActiveForm);
                    }
                }
            }
            else
            {
                if (serverTxt.Text == "")
                {
                    serverErrorLabel.Visible = true;
                }

                else
                {
                    serverErrorLabel.Visible = false;
                }



                if (databaseTxt.Text == "")
                {
                    DbErrorLabel.Visible = true;
                }
                else
                {
                    DbErrorLabel.Visible = false;
                }



                if (userTxt.Text == "")
                {
                    UserErrorLabel.Visible = true;
                }
                else
                {
                    UserErrorLabel.Visible = false;
                }


                if (passTxt.Text == "")
                {
                    PassErrorLabel.Visible = true;
                }
                else
                {
                    PassErrorLabel.Visible = false;
                }



                if (serverErrorLabel.Visible || DbErrorLabel.Visible || UserErrorLabel.Visible || PassErrorLabel.Visible)
                {
                    MainClass.showMessage("Fields with * are mandatory.", "error");
                }
                else
                {
                    connection = "Data Source=" + serverTxt.Text +
                                 ";Initial Catalog=" + databaseTxt.Text +
                                 ";User Id=" + userTxt.Text + ";Password="******";MultipleActiveResultSets=true";
                    saveConnection();
                    DialogResult dr = MessageBox.Show("Settings saved succesfully.");
                    if (dr == DialogResult.OK)
                    {
                        LoginScreen ls = new LoginScreen();
                        MainClass.showWindow(ls, this, MDI.ActiveForm);
                    }
                }
            }
        }
Esempio n. 28
0
 private void cartButton_Click(object sender, EventArgs e)
 {
     if (MainClass.checkControls(leftpanel).Count != 0)
     {
         MainClass.showMessage("Please enter all the required field", "error");
     }
     else
     {
         bool check = false;
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             if (row.Cells["itemIDGV"].Value.ToString() == itemDD.SelectedValue.ToString())
             {
                 check = true;
                 break;
             }
         }
         DataRowView drvFloor = floorDD.SelectedItem as DataRowView;
         DataRowView drvTable = tableDD.SelectedItem as DataRowView;
         DataRowView drvItems = itemDD.SelectedItem as DataRowView;
         try
         {
             if (check)
             {
                 MainClass.showMessage("Item added already!", "error");
             }
             else
             {
                 catID   = RetrivalData.CATEGORYID;
                 catName = RetrivalData.CATEGORYNAME;
                 if (orderDD.SelectedIndex == 0)
                 {
                     totalAmount    += Convert.ToSingle(priceTxt.Text) * Convert.ToSingle(numericUpDown1.Value);
                     totalLabel.Text = totalAmount.ToString();
                     dataGridView1.Rows.Add(null, Convert.ToInt32(tableDD.SelectedValue.ToString()),
                                            Convert.ToInt32(floorDD.SelectedValue.ToString()),
                                            catID, catName,
                                            Convert.ToInt32(itemDD.SelectedValue.ToString()),
                                            drvItems["Menu Name"],
                                            Convert.ToSingle(priceTxt.Text),
                                            Convert.ToInt32(numericUpDown1.Text),
                                            orderDD.SelectedItem.ToString(),
                                            drvFloor["Floor"],
                                            drvTable["Table Number"],
                                            null);
                 }
                 else if (orderDD.SelectedIndex == 1 || orderDD.SelectedIndex == 2)
                 {
                     totalAmount    += Convert.ToSingle(priceTxt.Text) * Convert.ToSingle(numericUpDown1.Value);
                     totalLabel.Text = totalAmount.ToString();
                     dataGridView1.Rows.Add(null, null, null, catID, catName, Convert.ToInt32(itemDD.SelectedValue.ToString()), drvItems["Menu Name"],
                                            Convert.ToSingle(priceTxt.Text),
                                            Convert.ToInt32(numericUpDown1.Text),
                                            orderDD.SelectedItem.ToString(), null,
                                            null, phonetxt.Text);
                 }
             }
         }
         catch (Exception)
         {
             MainClass.showMessage("Please enter all the fields.", "error");
         }
     }
     MainClass.sno(dataGridView1, "snoGV");
 }