internal static int GetWarrentyCount(Reciept Reciept, WarrentyItem Item) { int count = 0; using (Connection Connection = new Connection()) { count = Connection.WarrentyCount(Reciept.RecieptID, Item.ItemId); } return(count); }
private string GetPaymentItem(WarrentyItem item) { foreach (var x in this.WarrentySettingList) { if (item.GetItemBrand() == x.Brand.ToString()) { return(x.PaymentItem); } } return(null); }
internal static Warranty Warrenties(bool Updated) { Warranty warrenty = new Warranty(); if (POSConnection.State != System.Data.ConnectionState.Open) { POSConnection.Open(); SqlCommand command = new SqlCommand(SQL_SELECT_WARRENTY, POSConnection); WarrentyItem temp = new WarrentyItem(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { var warranty_id = reader.GetValue(0); var warranty_number = reader.GetValue(1); var show_room = reader.GetValue(2); var cash_memo = reader.GetValue(3); var item_code = reader.GetValue(4); var item_desc = reader.GetValue(5); var serial_number = reader.GetValue(6); var retail_price = reader.GetValue(7); var warranty_years = reader.GetValue(8); var bill_total = reader.GetValue(9); var issued_date = reader.GetValue(10); var customer_name = reader.GetValue(11); var customer_email = reader.GetValue(12); var customer_phone = reader.GetValue(13); var customer_address = reader.GetValue(14); var payment_cash_memo = reader.GetValue(15); var country = reader.GetValue(16); temp = new WarrentyItem() { WarrentyNumber = warranty_number.ToString(), ItemId = item_code.ToString(), Description = item_desc.ToString(), CustomerName = customer_name.ToString(), PaymentReciept = DataProvider.GetCashMemo(payment_cash_memo.ToString(), "ALL"), Reciept = DataProvider.GetCashMemo(cash_memo.ToString(), "ALL") }; warrenty.Add(temp); } reader.Close(); } return(warrenty); }
private void buttonOK_Click(object sender, EventArgs e) { WarrentyItem item = new WarrentyItem(); item.ItemId = Item.ItemId; item.Description = Item.Description; item.Barcode = Item.Barcode; item.LineNumber = Item.LineNumber; item.Quantity = Item.Quantity; item.NetAmount = Item.NetAmount; item.UnitSalePrice = Item.UnitSalePrice; item.NumberOfYears = (int)this.numericUpDown1.Value; item.WarrentyAmount = this.WarrentyAmount; item.SerialNumber = this.textBoxItemSerial.Text; Item.PaymentItem = GetPaymentItem(item); this.WarrentyItem = item; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
internal XX_EXTENDED_WARRANTY GetWattenty(String Parameter) { XX_EXTENDED_WARRANTY warrenty = new XX_EXTENDED_WARRANTY(); if (POSConnection.State != System.Data.ConnectionState.Open) { POSConnection.Open(); } SqlCommand command = new SqlCommand(SQL_SELECT_WARRENTY + " where " + Parameter, POSConnection); WarrentyItem temp = new WarrentyItem(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { warrenty.warranty_id = reader.GetValue(0); warrenty.warranty_number = reader.GetValue(1); warrenty.show_room = reader.GetValue(2); warrenty.cash_memo = reader.GetValue(3); warrenty.item_code = reader.GetValue(4); warrenty.item_desc = reader.GetValue(5); warrenty.serial_number = reader.GetValue(6); warrenty.retail_price = reader.GetValue(7); warrenty.warranty_years = reader.GetValue(8); warrenty.bill_total = reader.GetValue(9); warrenty.issued_date = reader.GetValue(10); warrenty.customer_name = reader.GetValue(11); warrenty.customer_email = reader.GetValue(12); warrenty.customer_phone = reader.GetValue(13); warrenty.customer_address = reader.GetValue(14); warrenty.payment_cash_memo = reader.GetValue(15); warrenty.country = reader.GetValue(16); } else { throw new Exception(); } reader.Close(); return(warrenty); }
private void buttonAddSerial_Click(object sender, EventArgs e) { WarrentyItem Slip = null; foreach (var warranty in Warranties) { if (warranty.ItemId == this.comboBoxWarrenties.Text) { Slip = warranty; } } if (Slip != null) { WarrentyItemSelction WarrentyItemSelction = new WarrentyItemSelction(); WarrentyItemSelction.Item = Slip; var result = WarrentyItemSelction.ShowDialog(this); /* * if (result == System.Windows.Forms.DialogResult.Cancel) * { * MessageBox.Show("Canceled"); * }*/ if (result == System.Windows.Forms.DialogResult.OK) { try { Slip.SerialNumber = Slip.SerialNumber + ";" + WarrentyItemSelction.WarrentyItem.SerialNumber; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } comboBoxWarrenties_SelectedIndexChanged(this.comboBoxWarrenties.SelectedIndex, new EventArgs()); }
internal string Insert(WarrentyItem x, string CashMemo, string CustomerName, string Email, string Phone, string Address, String Country) { int nextWarrenty = GetNextWarrenty(this.DedicatedConnection, this.DedicatedConnectionTransaction); string nextWarrentyNumber = CashMemo + "-" + nextWarrenty.ToString("0000000"); SqlCommand command = new SqlCommand(SQL_INSERT_WARRENTY, DedicatedConnection); command.Parameters.Clear(); command.Parameters.AddWithValue(@"@warranty_number", nextWarrentyNumber); command.Parameters.AddWithValue(@"@show_room", x.PaymentReciept.Store); command.Parameters.AddWithValue(@"@cash_memo", CashMemo); command.Parameters.AddWithValue(@"@item_code", x.ItemId); command.Parameters.AddWithValue(@"@item_desc", x.Description); command.Parameters.AddWithValue(@"@serial_number", x.SerialNumber); command.Parameters.AddWithValue(@"@retail_price", x.NetAmount / x.Quantity); command.Parameters.AddWithValue(@"@warranty_years", x.NumberOfYears); command.Parameters.AddWithValue(@"@bill_total", x.WarrentyAmount); command.Parameters.AddWithValue(@"@customer_name", CustomerName); command.Parameters.AddWithValue(@"@customer_email", Email); command.Parameters.AddWithValue(@"@customer_phone", Phone); command.Parameters.AddWithValue(@"@customer_address", Address); command.Parameters.AddWithValue(@"@payment_cash_memo", x.PaymentReciept.RecieptID); command.Parameters.AddWithValue(@"@country", Country); command.Transaction = DedicatedConnectionTransaction; command.ExecuteNonQuery(); command.CommandText = SQL_INSERT_REPLICATION; command.Parameters.Clear(); command.Parameters.AddWithValue("@Parameters", @"warranty_number='" + nextWarrentyNumber + "'"); try { command.ExecuteNonQuery(); } catch (Exception) { } x.WarrentyNumber = nextWarrentyNumber; return(nextWarrentyNumber); }
internal static DataTable DownloadWarrienties(int Start, int End, string LocationFilter, String WarrentyFilter, String RecieptFilter, String EmailFilter, String HasErrorsFilter) { String SQLQuery = SQL_SELECT_WARRENTY; const String WHERE = " WHERE "; const String AND = " AND "; bool andFlag = false; if (LocationFilter != null || WarrentyFilter != null || RecieptFilter != null || EmailFilter != null || HasErrorsFilter != null) { SQLQuery = String.Concat(SQLQuery, WHERE); } if (LocationFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " show_room = '" + LocationFilter + "'" : " show_room = '" + LocationFilter + "'"); andFlag = true; } if (WarrentyFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " warranty_number = '" + WarrentyFilter + "'" : " warranty_number = '" + WarrentyFilter + "'"); andFlag = true; } if (RecieptFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " cash_memo = '" + RecieptFilter + "'" : " cash_memo = '" + RecieptFilter + "'"); } if (EmailFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " customer_email = '" + EmailFilter : " customer_email = '" + EmailFilter); andFlag = true; } if (HasErrorsFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 " : " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 "); andFlag = true; } DataTable warrenty = new DataTable(); if (POSConnection.State != System.Data.ConnectionState.Open) { POSConnection.Open(); SqlCommand command = new SqlCommand(SQLQuery, POSConnection); WarrentyItem temp = new WarrentyItem(); using (SqlDataAdapter adaptor = new SqlDataAdapter(command)) { adaptor.Fill(warrenty); } } return(warrenty); }
internal static Warranty Warrenties(int Start, int End, string LocationFilter, String WarrentyFilter, String RecieptFilter, String EmailFilter, String HasErrorsFilter) { String SQLQuery = SQL_SELECT_WARRENTY; const String WHERE = " WHERE "; const String AND = " AND "; bool andFlag = false; if (LocationFilter != null || WarrentyFilter != null || RecieptFilter != null || EmailFilter != null || HasErrorsFilter != null) { SQLQuery = String.Concat(SQLQuery, WHERE); } if (LocationFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " show_room = '" + LocationFilter + "'" : " show_room = '" + LocationFilter + "'"); andFlag = true; } if (WarrentyFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " warranty_number = '" + WarrentyFilter + "'" : " warranty_number = '" + WarrentyFilter + "'"); andFlag = true; } if (RecieptFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " cash_memo = '" + RecieptFilter + "'" : " cash_memo = '" + RecieptFilter + "'"); } if (EmailFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " customer_email = '" + EmailFilter : " customer_email = '" + EmailFilter); andFlag = true; } if (HasErrorsFilter != null) { SQLQuery = String.Concat(SQLQuery, andFlag ? AND + " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 " : " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 "); andFlag = true; } Warranty warrenty = null; if (POSConnection.State != System.Data.ConnectionState.Open) { POSConnection.Open(); SqlCommand command = new SqlCommand(SQLQuery, POSConnection); WarrentyItem temp = new WarrentyItem(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { var warranty_id = reader.GetValue(0); var warranty_number = reader.GetValue(1); var show_room = reader.GetValue(2); var cash_memo = reader.GetValue(3); var item_code = reader.GetValue(4); var item_desc = reader.GetValue(5); var serial_number = reader.GetValue(6); var retail_price = reader.GetValue(7); var warranty_years = reader.GetValue(8); var bill_total = reader.GetValue(9); var issued_date = reader.GetValue(10); var customer_name = reader.GetValue(11); var customer_email = reader.GetValue(12); var customer_phone = reader.GetValue(13); var customer_address = reader.GetValue(14); var payment_cash_memo = reader.GetValue(15); var country = reader.GetValue(16); var error_message = reader.GetValue(17); if (warrenty == null) { warrenty = new Warranty() { } } ; temp = new WarrentyItem() { WarrentyNumber = warranty_number.ToString(), CustomerName = customer_name.ToString(), ItemId = item_code.ToString(), Description = item_desc.ToString(), IssuedDate = DateTime.Parse(issued_date.ToString()), SerialNumber = serial_number.ToString(), Email = customer_email.ToString(), Phone = customer_phone.ToString(), Address = customer_address.ToString(), WarrentyAmount = Int32.Parse(bill_total.ToString()), PaymentReciept = DataProvider.GetCashMemo(payment_cash_memo.ToString(), "ALL"), Reciept = DataProvider.GetCashMemo(cash_memo.ToString(), "ALL"), RecieptID = cash_memo.ToString(), NumberOfYears = Int32.Parse(warranty_years.ToString()), ErrorMessage = error_message.ToString() }; warrenty.Add(temp); } reader.Close(); } return(warrenty); }