예제 #1
0
        internal static RecieptItem Item(string ItemSearch)
        {
            RecieptItem Item = null;

            if (POSConnection.State != System.Data.ConnectionState.Open)
            {
                POSConnection.Open();
                SqlCommand command = new SqlCommand(SQL_ITEM, POSConnection);
                command.Parameters.AddWithValue("@ITEMID", ItemSearch.Trim());
                command.Parameters.AddWithValue("@ITEMBARCODE", ItemSearch.Trim());
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    Item = new RecieptItem()
                    {
                        Barcode      = reader.GetString(0),
                        Description  = reader.GetString(1),
                        ItemId       = reader.GetString(2),
                        LineNumber   = 1,
                        NetAmount    = reader.GetDecimal(3),
                        PaymentItem  = "",
                        PaymentUsage = 0,
                        Quantity     = 1
                    };
                }
                reader.Close();
            }
            return(Item);
        }
예제 #2
0
 private void buttonWarrentyPriceCheck_Click(object sender, EventArgs e)
 {
     this.IsBusy = true;
     if (this.textBoxItemSearch.Text.Trim().Length >= 13)
     {
         if (this.buttonWarrentyPriceCheck.Enabled)
         {
             RecieptItem RecieptItem = LSExtendedWarrenty.AppBase.DataHelper.DataProvider.GetItem(this.textBoxItemSearch.Text);
             if (RecieptItem == null)
             {
                 MessageBox.Show(this, "Item not found.", "Not Found");
             }
             else
             {
                 WarrentyItemSelction WarrentyItemSelction = new WarrentyItemSelction();
                 WarrentyItemSelction.Item = RecieptItem;
                 var result =
                     WarrentyItemSelction.ShowDialog(this);
             }
         }
     }
     else
     {
         MessageBox.Show("Please enter an Item Code or Barcode.", "Not Found");
     }
     this.IsBusy = false;
 }
예제 #3
0
        internal static List <WarretntySettings> WarrentySettings(RecieptItem Item)
        {
            List <WarretntySettings> WarrentySettingsList = new List <WarretntySettings>();

            if (POSConnection.State != System.Data.ConnectionState.Open)
            {
                POSConnection.Open();
                SqlCommand command = new SqlCommand(SQL_WARRENTY_SETTINGS, POSConnection);
                command.Parameters.AddWithValue(@"@ITEMID", Item.ItemId);
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    WarrentySettingsList.Add(new
                                             WarretntySettings()
                    {
                        NumberOfYears      = reader.GetInt32(0),
                        WarrentyPercentage = reader.GetInt32(1),
                        Brand       = reader.GetInt32(2),
                        PaymentItem = reader.GetString(3)
                    }
                                             );
                }
                reader.Close();
            }
            return(WarrentySettingsList);
        }
예제 #4
0
        internal static List <WarretntySettings> GetWarrentySettings(RecieptItem Item)
        {
            List <WarretntySettings> WarrentySettingsList = new List <WarretntySettings>();

            using (Connection Connection = new Connection())
            {
                WarrentySettingsList = Connection.WarrentySettings(Item);
            }
            if (WarrentySettingsList.Count == 0)
            {
                throw new NoWarrentySettingFoundException("No Warranty Settings Found for the Item: " + Item.ItemId + ".", "Cannot Add Warranty for Item.");
            }
            return(WarrentySettingsList);
        }
예제 #5
0
 private void dataGridViewRecieptItems_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         String selectedItemId = dataGridViewRecieptItems.Rows[e.RowIndex].Cells["ItemId"].Value.ToString();
         foreach (RecieptItem item in Reciept)
         {
             if (item.ItemId == selectedItemId)
             {
                 this.SelectedItem     = item;
                 this.textBoxItem.Text = item.ItemId;
             }
         }
     }
     catch (Exception) { }
 }
예제 #6
0
        internal Reciept Reciept(string RecieptNumber, string Selection)
        {
            Reciept Reciept = null;

            if (POSConnection.State != System.Data.ConnectionState.Open)
            {
                POSConnection.Open();
                SqlCommand command = new SqlCommand(SQL_RECIEPT_DETAILS, POSConnection);
                command.Parameters.AddWithValue("@RECEIPTID", RecieptNumber);
                command.Parameters.AddWithValue("@SELECTION", Selection);
                SqlDataReader reader   = command.ExecuteReader();
                RecieptItem   tempItem = null;
                int           i        = 0;
                while (reader.Read())
                {
                    i++;
                    if (i == 1)
                    {
                        Reciept = new Reciept();
                        Reciept.TransactionID   = reader.GetString(0);
                        Reciept.RecieptID       = reader.GetString(1);
                        Reciept.Store           = reader.GetString(2);
                        Reciept.Staff           = reader.GetString(3);
                        Reciept.StaffName       = reader.GetString(4);
                        Reciept.TransactionDate = reader.GetDateTime(5);
                    }
                    try
                    {
                        tempItem             = new RecieptItem();
                        tempItem.LineNumber  = (int)reader.GetDecimal(6);
                        tempItem.ItemId      = reader.GetString(7);
                        tempItem.Quantity    = (int)reader.GetDecimal(8);
                        tempItem.NetAmount   = reader.GetDecimal(9);
                        tempItem.Description = reader.GetString(10);
                        tempItem.Barcode     = reader.GetString(11);
                        Reciept.Add(tempItem);
                    }
                    catch (Exception ex) { throw ex; }
                }
                reader.Close();
            }
            return(Reciept);
        }
예제 #7
0
        public Reciept ApplyRule(Reciept reciept)
        {
            if (reciept == null || reciept.RecieptItems.Count == 0)
            {
                throw new ArgumentException("Price list is null or empty.");
            }

            RecieptItem recieptItem = reciept.RecieptItems.FirstOrDefault(i =>
                                                                          String.Compare(i.Name, "orange", StringComparison.OrdinalIgnoreCase) == 0);

            if (recieptItem == null || recieptItem.Quantity == 0)
            {
                return(reciept);
            }

            int quantitywithoffer = (int)recieptItem.Quantity / 3;
            int leftover          = recieptItem.Quantity - quantitywithoffer * 3;

            recieptItem.Quantity = quantitywithoffer * 2 + leftover;
            return(reciept);
        }
예제 #8
0
        private void textBoxItem_KeyPress(object sender, KeyPressEventArgs e)
        {
            this.SelectedItem = null;
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                if (Reciept != null)
                {
                    foreach (RecieptItem item in Reciept)
                    {
                        if ((item.Barcode == this.textBoxItem.Text) || (item.ItemId == this.textBoxItem.Text))
                        {
                            this.SelectedItem     = item;
                            this.textBoxItem.Text = item.ItemId;
                        }
                    }

                    if (SelectedItem == null)
                    {
                        String ItemId =
                            LSExtendedWarrenty.AppBase.DataHelper.DataProvider.GetItemId(textBoxItem.Text, Reciept.TransactionID);
                        foreach (RecieptItem item in Reciept)
                        {
                            if (item.ItemId == ItemId)
                            {
                                this.SelectedItem     = item;
                                this.textBoxItem.Text = item.ItemId;
                            }
                        }
                    }
                    if (SelectedItem == null)
                    {
                        MessageBox.Show(this, "Item not found in the selected Receipt", "Item Not Found");
                    }
                }
                else
                {
                    MessageBox.Show(this, "No Receipt selected.", "No Receipt");
                }
            }
        }
예제 #9
0
 private void textBoxItemSearch_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == Convert.ToChar(Keys.Enter))
     {
         this.IsBusy = true;
         if (this.buttonWarrentyPriceCheck.Enabled)
         {
             RecieptItem RecieptItem = LSExtendedWarrenty.AppBase.DataHelper.DataProvider.GetItem(this.textBoxItemSearch.Text);
             if (RecieptItem == null)
             {
                 MessageBox.Show(this, "Item not found.", "Not Found");
             }
             else
             {
                 WarrentyItemSelction WarrentyItemSelction = new WarrentyItemSelction();
                 WarrentyItemSelction.Item = RecieptItem;
                 var result =
                     WarrentyItemSelction.ShowDialog(this);
             }
         }
         this.IsBusy = false;
     }
 }