Beispiel #1
0
        public billdetail SearchCustomer(string cuName)
        {
            billdetail cd = null;

            SortByName();
            int pos = GetPosition(cuName);


            if (pos != -1)
            {
                using (FileStream LoginReader = new FileStream("BillDetails.txt", FileMode.Open))
                {
                    cd = new billdetail();
                    string line = "";
                    int    chr;
                    LoginReader.Seek(pos, SeekOrigin.Begin);
                    while ((chr = LoginReader.ReadByte()) > 0)
                    {
                        char c;
                        c = Convert.ToChar(chr);
                        if (c == '$')
                        {
                            break;
                        }
                        line += c;
                    }
                    string[] subStr = line.Split('|');
                    cd.Customer_ID = int.Parse(subStr[0]);
                    cd.Room_Type   = subStr[1];
                    cd.Payment     = subStr[2];
                }
                return(cd);
            }
            return(cd);
        }
        private void btnsearch_Click(object sender, EventArgs e)
        {
            int id;

            bool flag = int.TryParse(txtcustid.Text, out id);

            if (!flag)
            {
                MessageBox.Show("Invalid ID");
                return;
            }


            billcontroller std = new billcontroller();
            billdetail     i   = std.Searchcustomer(id);

            if (i != null)
            {
                a = true;
                txtcustid.Text = i.Customer_ID.ToString();
            }
            else
            {
                a = false;
                MessageBox.Show("Record Not Found");
            }
            billcontroller sc = new billcontroller();

            dt = new DataTable();
            if (a == true)
            {
                dt.Columns.Add("Customer_ID", System.Type.GetType("System.String"));
                dt.Columns.Add("Room_Type", System.Type.GetType("System.String"));
                dt.Columns.Add("Payment", System.Type.GetType("System.String"));

                List <billdetail> d = sc.GetAllitem();

                foreach (var s in d)
                {
                    if (id == s.Customer_ID)
                    {
                        dt.Rows.Add(new object[] { s.Customer_ID, s.Room_Type, s.Payment });
                    }
                }
                dataGridView1.DataSource = dt;
            }
        }
Beispiel #3
0
        public billdetail Searchcustomer(int Boid)
        {
            billdetail cd  = null;
            int        pos = GetPosition(Boid);

            if (pos != -1)
            {
                using (FileStream LoginReader = new FileStream("BillDetails.txt", FileMode.Open))
                {
                    cd = new billdetail();
                    string line = "";
                    int    chr;
                    LoginReader.Seek(pos, SeekOrigin.Begin);
                    while ((chr = LoginReader.ReadByte()) > 0)
                    {
                        char c;
                        c = Convert.ToChar(chr);
                        if (c == '$')
                        {
                            break;
                        }
                        line += c;
                    }
                    string[] subStr = line.Split('|');
                    try
                    {
                        cd.Customer_ID = int.Parse(subStr[0]);
                        cd.Room_Type   = subStr[1];
                        cd.Payment     = subStr[2];
                    }
                    catch (Exception e)
                    {
                        Console.Out.WriteLine(e.StackTrace);
                        Console.Out.WriteLine("inside search customer error ---------------------");
                    }
                }
                return(cd);
            }
            return(cd);
        }