void RefreshListItem(int rowIdx, int friendIdx) { ListRow row = GetRow(rowIdx); LobbyGang.FriendInfo friend = GetFriend(friendIdx); if (friend != null) { row.FriendIndex = friendIdx; int statusTextId; if (friend.IsReady) { statusTextId = 0109047; } else if (friend.IsWaiting) { statusTextId = 0109046; } else if (friend.IsOnline) { statusTextId = 0109044; } else if (friend.IsPlaying) { statusTextId = 0109063; } else { statusTextId = 0109045; } if (row.Root.Visible == false) { row.Root.Show(true, true); } row.Name.SetNewText(GuiBaseUtils.FixNameForGui(friend.Nickname)); row.Status.SetNewText(string.Format("({0})", TextDatabase.instance[statusTextId])); row.RankValue.SetNewText(friend.Rank.ToString()); row.RankIcon.State = string.Format("Rank_{0}", Mathf.Min(friend.Rank, row.RankIcon.Count - 1).ToString("D2")); bool available = LobbyGang.FriendsInvited < MAX_INVITES ? friend.IsOnline : false; bool canInvite = available ? friend.CanInvite : false; row.AddButton.IsDisabled = friend.IsInvited ? true : !canInvite; row.RemoveButton.IsDisabled = friend.IsInvited ? false : !available; row.WaitingBg.Widget.Show(friend.IsWaiting, true); row.ReadyBg.Widget.Show(friend.IsReady, true); row.AddButton.Widget.Show(!friend.IsInvited && available, true); row.RemoveButton.Widget.Show(friend.IsInvited && available, true); } else { row.FriendIndex = -1; row.Root.Show(false, true); } }
private void HighlighItemChapterOutOfSequence(ListRow row, ListViewItem viewItem) { if (row.PossibleError) { viewItem.BackColor = Color.LightPink; } }
bool RefreshListItem(int rowIdx, int friendIdx) { ListRow row = GetRow(rowIdx); FriendInfo friend = GetFriend(friendIdx); if (friend != null) { row.FriendIndex = friendIdx; int statusTextId = friend.IsReady ? 0109047 : 0109046; if (row.Root.Visible == false) { row.Root.Show(true, true); } row.Name.SetNewText(GuiBaseUtils.FixNameForGui(friend.Nickname)); row.Status.SetNewText(string.Format("({0})", TextDatabase.instance[statusTextId])); row.RankValue.SetNewText(friend.Rank.ToString()); row.RankIcon.State = string.Format("Rank_{0}", Mathf.Min(friend.Rank, row.RankIcon.Count - 1).ToString("D2")); row.WaitingBg.Widget.Show(!friend.IsReady, true); row.ReadyBg.Widget.Show(friend.IsReady, true); return(friend.IsReady); } else { row.FriendIndex = -1; row.Root.Show(false, true); return(false); } }
public SimpleListTable() : base() { InitializeComponent(); Header = new ListRow(); /* * _header.VerticalAlignment = System.Windows.VerticalAlignment.Center; * _header.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; * _header.Orientation = Orientation.Horizontal; */ this.PropertyChanged += new PropertyChangedEventHandler(SimpleListTable_PropertyChanged); for (int i = 0; i < 4; i++) { AddTitleColumn(i, "test" + i, 50); } AddValue(1, 2, 3, 4); AddValue(1, 2, 3, 4); AddValue(1, 2, 3, 4); AddValue(1, 2, 3, 4); AddValue(1, 2, 3, 4); /* * this.DataList.Add(new Object[] { "name1", 0, true }); * this.DataList.Add(new Object[] { "name2", 0, true }); * this.DataList.Add(new Object[] { "name3", 0, true }); * this.DataList.Add(new Object[] { "name4", 0, true }); * * * Category = "cat1"; * this.ContentTemplate = this.Resources["dTemplate"] as DataTemplate; */ }
private void GetBikeList(ListRow currentRow) { List <string> bikes = new List <string>(); int startIndex = 8; while (currentRow.Range[0, startIndex] != string.Empty) { } }
public string EnregistrerArticle(ListRow row, string fichier, string ctNum) { BaseCialAbstract.setDefaultParams(fichier); Repository repos = new Repository(); BaseCialAbstract.setDefaultParams(repos.getDbListFromContext().First(db => db.name.Contains("TARIF")).gcmFile); return(repos.EnregistrerArticle(row, ctNum)); }
void rowCheckboxClicked(ListRow row, bool?check = null) { for (int i = 0; i < row.Count; i++) { if (row[i] is CheckBox) { Boolean isChecked = (Boolean)((row[i] as CheckBox).IsChecked); (row[i] as CheckBox).IsChecked = (check != null)? check : !isChecked; } } }
/// <summary> /// Добавить маршрут в таблицу /// </summary> /// <param name="mapDelivery"></param> /// <returns></returns> public int CreateRoute(List <DeliveryPoint> mapDelivery) { DeliveryPoint LastPoint = RoutesList.Last(); int idRoute = LastPoint.Id + 1; int priorityNewRoute = 2; //Поиск максимального приоритета, из всех где встречается клиент foreach (DeliveryPoint point in mapDelivery) { List <int> routes = (from p in RoutesList where p.IdCustomer == point.IdCustomer select p.PriorityRoute ).Distinct().ToList(); int maxPriority = 0; if (routes.Count > 0) { maxPriority = routes.Max(); } priorityNewRoute = maxPriority > priorityNewRoute ? maxPriority + 1 : priorityNewRoute; } int priorityPoint = 0; foreach (DeliveryPoint point in mapDelivery) { RoutesTable.ListRows.Add(); ListRow row = RoutesTable.ListRows[RoutesTable.ListRows.Count]; row.Range[1, RoutesTable.ListColumns["Id route"].Index].Value = idRoute; row.Range[1, RoutesTable.ListColumns["Priority route"].Index].Value = priorityNewRoute; row.Range[1, RoutesTable.ListColumns["Priority point"].Index].Value = ++priorityPoint; row.Range[1, RoutesTable.ListColumns["Получатель материала"].Index].Value = point.IdCustomer; row.Range[1, RoutesTable.ListColumns["City"].Index].Value = point.City; //поиск этого же Получателя в другой строке string customerName = string.IsNullOrEmpty(point.Customer) ? "" : point.Customer; DeliveryPoint findPoint = RoutesList.Find(x => x.IdCustomer == point.IdCustomer && x.Customer != ""); if (!string.IsNullOrWhiteSpace(findPoint.Customer)) { row.Range[1, RoutesTable.ListColumns["Город"].Index].Value = findPoint.CityLongName; row.Range[1, RoutesTable.ListColumns["Маршрут"].Index].Value = findPoint.Route; row.Range[1, RoutesTable.ListColumns["Направление"].Index].Value = findPoint.RouteName; row.Range[1, RoutesTable.ListColumns["Номер клиента"].Index].Value = findPoint.CustomerNumber; if (!string.IsNullOrWhiteSpace(customerName)) { customerName = findPoint.Customer; } } row.Range[1, RoutesTable.ListColumns["Клиент"].Index].Value = point.Customer; row.Range[1, RoutesTable.ListColumns["Add"].Index].Value = "Auto"; } RoutesList = null; return(idRoute); }
static object SpecificationListRow(ListRow sig, string action) { return(X("specificationListRow", X("category", "EDUCATION"), X("code", sig.Code), X("amount", sig.Amount), action.IsEmpty() ? null : X("action", action), X("price", sig.Price), X("description", sig.Description) )); }
/// <summary> /// 選択した薬をパラメータより削除 /// </summary> /// <param name="selectedItem">選択した薬</param> public void DeleteDrug(ListRow selectedItem) { var index = selectedItem.Index; if (-1 < index && index < _Parameter.Drug.Drugs.Count) { var drug = _Parameter.Drug.Drugs[index]; // 薬削除後、一覧を再作成 _Parameter.DeleteDrug(drug); MakeRows(); } }
/// <summary> /// 頓服服用 /// </summary> /// <param name="selectedItem">選択した薬</param> public void DrugToBeTaken(ListRow selectedItem) { var index = selectedItem.Index; if (-1 < index && index < _Parameter.Drug.Drugs.Count) { var drug = _Parameter.Drug.Drugs[index]; // 服用処理後、薬切れFLGの更新 _Parameter.TakeMedicineToBeTaken(drug); selectedItem.IsPrescription = drug.IsPrescriptionAlarm; } }
public List <ListRow> GetListContent(int ListID, int UserID) { try { List <ListRow> ListOfGames = new List <ListRow>(); using (var conn = new SqlConnection(GetConnectionString())) { var cmd = new SqlCommand("AppSchema.Usp_GetListContent", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ListID", SqlDbType.Int).Value = ListID; cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = UserID; conn.Open(); using (var reader = cmd.ExecuteReader()){ var idx_GameID = reader.GetOrdinal("GameID"); var idx_ListRowID = reader.GetOrdinal("ListRowID"); var listrowObj = new ListRow(); //if (reader.Read()) { //Vi kontrollerar först att det faktiskt finns poster att hämta ut, annars måste 0:värderna användas (se 4 och 6 rader längre ner) och dem ger error.. while (reader.Read()) { ListOfGames.Add(new ListRow { GameID = reader.IsDBNull(idx_GameID) ? 0 : reader.GetInt32(idx_GameID), //om listan ej har rader, så blir gameID 0... ListID = ListID, ListRowID = reader.IsDBNull(idx_ListRowID) ? 0 : reader.GetInt32(idx_ListRowID) }); // om listan ej har rader så är den inte funktionell, vi vill itne skicka tillbaka en icke funktionell lista, därför tar vi bort den posten // om så är fallet. if (ListOfGames[ListOfGames.Count - 1].GameID == 0 || ListOfGames[ListOfGames.Count - 1].ListRowID == 0) // man tar minus 1 för att hamna på rätt index... { ListOfGames.RemoveAt(ListOfGames.Count - 1); //tar b ort senaste tillagda värdet.. } } //} } conn.Close(); return(ListOfGames); } } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
private void InitSampleList() { foreach (WorldObject worldObject in Globals.Core.WorldFilter.GetByContainer(Globals.Core.CharacterFilter.Id)) { ListRow row = SampleList.Add(); row[0][1] = worldObject.Icon + 0x6000000; // Notice we're using an index of 1 for the second parameter. That's because this is a DecalControls.IconColumn column. row[1][0] = worldObject.Name; // Also note that you can create an empty column. In our mainView.xml we have: // <column progid="DecalControls.TextColumn" name="colF" /> // It is column index 5 and has no size associated with it. You can use this column to store an id of an item, or other misc data that you can use // later to grab info about the row, or maybe its sort order, etc.. // To clear the list you can do: // SampleList.Clear(); // If we want to check if this item is equipped, we could do the following if (worldObject.Values(LongValueKey.EquippedSlots) > 0) { } // This check will pass if the object is wielded // Take note that someone else might be wielding this object. If you want to know if its wielded by YOU, you need to add another check. if (worldObject.Values(LongValueKey.Slot, -1) == -1) { } // You can get an items current mana, but only if the item has been id'd, otherwise it will just return 0. if (worldObject.HasIdData) { int currentMana = worldObject.Values(LongValueKey.CurrentMana); } // But also note that we don't know how long ago this item has been id'd. Maybe it was id'd an hour ago? The mana data would be erroneous. // So, we could get fresh id data for the object with the following: // Globals.Host.Actions.RequestId(worldObject.Id); // But now note that it may take a second or so to get that id data. So if we did the following: // Globals.Host.Actions.RequestId(worldObject.Id); // worldObject.Values(LongValueKey.CurrentMana) <-- This would still be the OLD information and not the new because the above statement hasn't finished. } }
public ListTable() : base() { InitializeComponent(); Rows = new List <ListRow>(); Header = new ListRow(); //DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal, Dispatcher); //timer.Interval = new TimeSpan(2000); _clickCounter = new ClickCounter(200, this); _clickCounter.OnCountedClick += new CountedClickEventHandler(_clickCounter_OnCountedClick); ActionOnDoubleClicked = Actions.CheckBoxChecked; ActionOnClicked = Actions.Modify; _rh = new ResourceHandler(this.Resources); _rh.setControl(typeof(CheckBox), "CheckBoxTemplate"); _rh.setControl(typeof(Rectangle), "SeperatorLine"); _rh.SetStyle(_sep); _sep.Width = 1; RowHeight = 20; _sep.Height = 16; Header.ItemHorizontalAlignment = System.Windows.HorizontalAlignment.Center; Header.setSeperator(_sep); Header.Height = RowHeight; //E_ListRowClicked += new ListRowClickEventHandler(ListTable_E_ListRowClicked); //TestData(); //this.ContentTemplate = this.Resources["dTemplate"] as DataTemplate; //this.ContentTemplate = this.Resources["noTitleTemplate"] as DataTemplate; UIElementCollection uilist = ((this.ContentTemplate as DataTemplate).LoadContent() as Grid).Children; foreach (UIElement uie in uilist) { if (uie is ListView) { _listView = uie as ListView; break; } } //_listView.ItemsSource = Rows; }
GUIBase_List PrepareList(string listName, bool state) { GUIBase_List list = GuiBaseUtils.GetControl <GUIBase_List>(Layout, listName); if (state == true) { list.OnUpdateRow += OnUpdateListRow; } else { list.OnUpdateRow -= OnUpdateListRow; } // prepare list if (m_Rows.Length != list.numOfLines) { m_Rows = new ListRow[list.numOfLines]; for (int idx = 0; idx < list.numOfLines; ++idx) { GUIBase_Widget root = list.GetWidgetOnLine(idx); Transform trans = list.GetWidgetOnLine(idx).transform; ListRow row = new ListRow() { Root = root, Name = trans.FindChild(LISTITEM_NAME).GetComponent <GUIBase_Label>(), Status = trans.FindChild(LISTITEM_STATUS).GetComponent <GUIBase_Label>(), RankValue = trans.FindChild(LISTITEM_RANKVALUE).GetComponent <GUIBase_Label>(), RankIcon = trans.FindChild(LISTITEM_RANKICON).GetComponent <GUIBase_MultiSprite>(), WaitingBg = trans.FindChild(LISTITEM_WAITINGBG).GetComponent <GUIBase_Sprite>(), ReadyBg = trans.FindChild(LISTITEM_READYBG).GetComponent <GUIBase_Sprite>(), }; m_Rows[idx] = row; } } return(list); }
public void AddValue(params object[] values) { if (values == null || values.Length == 0) { return; } if (values != null && values[0] is object[]) { values = values[0] as object[]; } List <UIElement> elList = new List <UIElement>(); UIElement element; for (int i = 0; i < values.Length; i++) { element = WpfFinder.getUiElement(values[i]); elList.Add(element); } ListRow row = new ListRow(_wid, 20, true, elList); _rows.Add(row); DataList.Items.Add(row); }
LobbyGang.FriendInfo GetFriendByRowIdx(int rowIdx) { ListRow row = GetRow(rowIdx); return(row != null?GetFriend(row.FriendIndex) : null); }
GUIBase_List PrepareList(string listName, bool state) { GUIBase_List list = GuiBaseUtils.GetControl <GUIBase_List>(Layout, listName); if (state == true) { list.OnUpdateRow += OnUpdateListRow; } else { list.OnUpdateRow -= OnUpdateListRow; } // prepare list if (m_Rows.Length != list.numOfLines) { m_Rows = new ListRow[list.numOfLines]; for (int idx = 0; idx < list.numOfLines; ++idx) { GUIBase_Widget root = list.GetWidgetOnLine(idx); Transform trans = list.GetWidgetOnLine(idx).transform; ListRow row = new ListRow() { Root = root, Name = trans.FindChild(LISTITEM_NAME).GetComponent <GUIBase_Label>(), Status = trans.FindChild(LISTITEM_STATUS).GetComponent <GUIBase_Label>(), RankValue = trans.FindChild(LISTITEM_RANKVALUE).GetComponent <GUIBase_Label>(), RankIcon = trans.FindChild(LISTITEM_RANKICON).GetComponent <GUIBase_MultiSprite>(), WaitingBg = trans.FindChild(LISTITEM_WAITINGBG).GetComponent <GUIBase_Sprite>(), ReadyBg = trans.FindChild(LISTITEM_READYBG).GetComponent <GUIBase_Sprite>(), AddButton = trans.FindChild(LISTITEM_ADDBUTTON).GetComponent <GUIBase_Button>(), RemoveButton = trans.FindChild(LISTITEM_REMOVEBUTTON).GetComponent <GUIBase_Button>() }; m_Rows[idx] = row; } } // register delegates for (int idx = 0; idx < m_Rows.Length; ++idx) { ListRow row = m_Rows[idx]; if (state == true) { int rowIdx = idx; row.AddButton.RegisterTouchDelegate3((widget, evt) => { OnAddFriend(rowIdx, widget, evt); }); row.RemoveButton.RegisterTouchDelegate3((widget, evt) => { OnRemoveFriend(rowIdx, widget, evt); }); } else { row.AddButton.RegisterTouchDelegate3(null); row.RemoveButton.RegisterTouchDelegate3(null); } } return(list); }
protected void MouseBtnClicked(object sender, CountedClickEventArgs e) { //CountedClickEventArgs e = _clickCounter.Args;// BtnArgs; DependencyObject obj = e.MouseBtnArgs.OriginalSource as DependencyObject; if (obj.DependencyObjectType.IsSubclassOf(DependencyObjectType.FromSystemType(typeof(UIElement)))) { // if (obj.DependencyObjectType.IsSubclassOf(DependencyObjectType.FromSystemType(typeof(Shape)))) { return; } } else { return; } MouseButtonEventArgs mbe = e.MouseBtnArgs as MouseButtonEventArgs; ListBox view = (e.Sender as ListBox); ListRow row = view.SelectedItem as ListRow; ListRowClickEventArgs arg = new ListRowClickEventArgs(); try { arg.ListObj = view; arg.ListRowItem = view.SelectedItem as ListRow; arg.rowIndex = Rows.IndexOf(arg.ListRowItem); arg.colIndex = (arg.ListRowItem == null) ? -1 : (arg.ListRowItem.IndexOf(e.MouseBtnArgs.OriginalSource as UIElement)); if (arg.rowIndex < 0 || arg.colIndex < 0) { if (ListRow.ActivatedRow != null) { ListRow.DeActivate(); } return; } } catch (Exception ex) { throw ex; } if (row == null) { return; } //try { if (e.Count == 1) { if (ActionOnClicked == Actions.CheckBoxChecked) { rowCheckboxClicked(row); } else if (ActionOnClicked == Actions.Modify) { if (_editables[arg.colIndex]) { row.setModifyMode(arg.colIndex); } } if (E_ListRowClicked != null) { E_ListRowClicked(e.Sender, arg); } } else if (e.Count == 2) { if (ActionOnDoubleClicked == Actions.CheckBoxChecked) { rowCheckboxClicked(row); } else if (ActionOnDoubleClicked == Actions.Modify) { if (_editables[arg.colIndex]) { row.setModifyMode(arg.colIndex); } } if (E_ListRowDoubleClicked != null) { E_ListRowDoubleClicked(e.Sender, arg); } } } //catch (Exception ex) { // throw ex; } BeforeClickedRow = row.Index; }
void AddDataRowInvoke() { //if (lv == null) { // return; } //else { double height = ad_height; object relativeObj = ad_relativeObj; object[] values = ad_values; List <UIElement> elList = new List <UIElement>(); UIElement element; //try { for (int i = 0; i < values.Length; i++) { element = (values[i] is UIElement) ? values[i] as UIElement : WpfFinder.getUiElement(values[i]); if (element is CheckBox) { element = getStyledCheckBox(((element as CheckBox).IsChecked)); } else if (element is TextBlock) { (element as TextBlock).ToolTip = (element as TextBlock).Text; element.SetValue(FontFamilyProperty, this.FontFamily); element.SetValue(FontSizeProperty, this.FontSize); element.SetValue(ForegroundProperty, this.Foreground); } else if (element is Image) { } elList.Add(element); /* * if (element is CheckBox) * { * (element as CheckBox).Checked += new RoutedEventHandler(OnCheckBoxClicked); * (element as CheckBox).Unchecked += new RoutedEventHandler(OnCheckBoxClicked); * } */ } ListRow row = new ListRow(_wid, RowHeight, true, elList); row.ColName = Header.ColName; row.RelativeObject = relativeObj; row.ItemHorizontalAlignment = DataHorizonAlignment; row.Index = Rows.Count; row.E_TextChanged += new ListRowTextChangedEventHandler(row_E_TextChanged); row.E_CheckBoxChanged += new ListCheckedEventHandler(OnCheckBoxClicked); row.E_ComboBoxChanged += new ListComboBoxEventHandler(row_E_ComboBoxChanged); row.Editables = _editables; _tempNewList.Add(row); // if(_listView!=null) // _listView.Items.Add(row); } //catch (Exception e) { //throw e; } //NotifyPropertyChanged("Rows"); } }
public ListRowChangeEvent(ListRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public string EnregistrerArticle(ListRow row, string ctNum) { try { using (SqlConnection cnx = new SqlConnection(cnxString)) { cnx.Open(); SqlTransaction transaction = cnx.BeginTransaction(); try { #region init vars ListObject tableArticle = row.Parent; string refMag = (string)row.Range.Columns[tableArticle.ListColumns["REF MAG"].Index].value; string arRef = (string)row.Range.Columns[tableArticle.ListColumns["AR_Ref"].Index].value; int sommeil = $"{row.Range.Columns[tableArticle.ListColumns["SOMMEIL"].Index].value}" == "M" ? 1 : 0; string supp = $"{row.Range.Columns[tableArticle.ListColumns["SUPP"].Index].value}" == "S" ? "Oui" : "Non"; string suppUsine = $"{row.Range.Columns[tableArticle.ListColumns["SUPP USINE"].Index].value}" == "U" ? "Oui" : "Non"; int publieWeb = $"{row.Range.Columns[tableArticle.ListColumns["PUBLIE WEB"].Index].value}" == "W" ? 1 : 0; string designation = (string)row.Range.Columns[tableArticle.ListColumns["DESIGNATION"].Index].value; string famille = (string)row.Range.Columns[tableArticle.ListColumns["FAMILLE"].Index].value; bool isPrincipal = $"{row.Range.Columns[tableArticle.ListColumns["PRINCIPAL"].Index].value}" == "P"; double nvPxNetAchat = row.Range.Columns[tableArticle.ListColumns["NV PX NET ACHAT"].Index].value; double arCoef = row.Range.Columns[tableArticle.ListColumns["NV COEF SUR PX NET"].Index].value; double nvPxVente = row.Range.Columns[tableArticle.ListColumns["NV PX VENTE"].Index].value; double arPoidsNet = row.Range.Columns[tableArticle.ListColumns["POIDS"].Index].value; int unitePoids = unitesPoids.First(u => u.Value == row.Range.Columns[tableArticle.ListColumns["UNITE POIDS"].Index].value).Key; string gencodArt = row.Range.Columns[tableArticle.ListColumns["GENCOD ART"].Index].value != null ? row.Range.Columns[tableArticle.ListColumns["GENCOD ART"].Index].value.ToString() : string.Empty; string uniteVen = row.Range.Columns[tableArticle.ListColumns["UNITE VENTE"].Index].value; int coNo = int.Parse($"{row.Range.Columns[tableArticle.ListColumns["CO_No"].Index].value}"); string enumCond = (string)row.Range.Columns[tableArticle.ListColumns["ENUM COND"].Index].value; double condQt = row.Range.Columns[tableArticle.ListColumns["COND QT"].Index].value; int ag1 = int.Parse($"{row.Range.Columns[tableArticle.ListColumns["AG1"].Index].value}"); int ag2 = int.Parse($"{row.Range.Columns[tableArticle.ListColumns["AG2"].Index].value}"); bool isGamme = ag1 != 0 || ag2 != 0; bool isCond = coNo > 0; bool isCondPrinc = row.Range.Columns[tableArticle.ListColumns["CO_Principal"].Index].value == 1; bool isGammeOrCond = isGamme | isCond; string refFourn = row.Range.Columns[tableArticle.ListColumns["REF FOURN"].Index].value != null ? row.Range.Columns[tableArticle.ListColumns["REF FOURN"].Index].value.ToString() : string.Empty; double nvPxFourn = row.Range.Columns[tableArticle.ListColumns["NV PX FOURN"].Index].value; double afRemise = row.Range.Columns[tableArticle.ListColumns["NV REMISE"].Index].value; double afConv = row.Range.Columns[tableArticle.ListColumns["CONV VEN"].Index].value; double afConvDiv = row.Range.Columns[tableArticle.ListColumns["CONV ACH"].Index].value; string gencodFourn = row.Range.Columns[tableArticle.ListColumns["GENCOD FOURN"].Index].value != null ? row.Range.Columns[tableArticle.ListColumns["GENCOD FOURN"].Index].value.ToString() : string.Empty; double afColisage = row.Range.Columns[tableArticle.ListColumns["COLISAGE"].Index].value; double afQteMin = row.Range.Columns[tableArticle.ListColumns["QEC"].Index].value; string afUnite = row.Range.Columns[tableArticle.ListColumns["UNITE ACHAT"].Index].value; bool majArticle = row.Range.Columns[tableArticle.ListColumns["MAJ ARTICLE"].Index].value == 1; double nvPxTTC = row.Range.Columns[tableArticle.ListColumns["NV PX TTC"].Index].value; string ecoTaxe = row.Range.Columns[tableArticle.ListColumns["ECO TAXE"].Index].value ?? string.Empty; double ecoTaxeQt = row.Range.Columns[tableArticle.ListColumns["QT ECO TAXE"].Index].value ?? 0; string refFournBase = row.Range.Columns[tableArticle.ListColumns["REF FOURN BASE"].Index].value; string gamme1 = row.Range.Columns[tableArticle.ListColumns["GAMME 1"].Index].value; string gamme2 = row.Range.Columns[tableArticle.ListColumns["GAMME 2"].Index].value; double nvPxAch = row.Range.Columns[tableArticle.ListColumns["NV PX ACHAT"].Index].value; string codeDouanier = row.Range.Columns[tableArticle.ListColumns["CODE DOUANIER"].Index].value != null ? row.Range.Columns[tableArticle.ListColumns["CODE DOUANIER"].Index].value.ToString() : string.Empty; #endregion #region Protection lignes Gamme/Cond manquantes // Vérifie que l'article à gamme/cond a bien toutes les lignes de présentes dans le fichier excel if (isGammeOrCond) { using (SqlConnection cnx2 = new SqlConnection(cnxString)) { cnx2.Open(); if (isGamme) { using (SqlCommand cmd = cnx2.CreateCommand()) { cmd.CommandText = "SELECT COUNT(*) AS Total FROM F_ARTENUMREF WHERE AR_Ref = @arRef"; cmd.Parameters.AddWithValue("@arRef", arRef); using (SqlDataReader reader = cmd.ExecuteReader()) { reader.Read(); if (reader["Total"].ToString() != row.Application.WorksheetFunction.CountIf(tableArticle.ListColumns["AR_Ref"].Range, arRef).ToString()) { throw new Exception("Des lignes de gamme sont manquantes dans le fichier."); } } } } if (isCond) { using (SqlCommand cmd = cnx2.CreateCommand()) { cmd.CommandText = "SELECT COUNT(*) AS Total FROM F_CONDITION WHERE AR_Ref = @arRef"; cmd.Parameters.AddWithValue("@arRef", arRef); using (SqlDataReader reader = cmd.ExecuteReader()) { reader.Read(); if (reader["Total"].ToString() != row.Application.WorksheetFunction.CountIf(tableArticle.ListColumns["AR_Ref"].Range, arRef).ToString()) { throw new Exception("Des lignes de conditionnement sont manquantes dans le fichier."); } } } } } } #endregion // Mise à jour de la fiche article, fiche fournisseur // Préparation des autres tables si conditionnements/gammes if (majArticle) { #region F_ARTICLE using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = @"UPDATE F_ARTICLE SET [AR_Sommeil] = @sommeil, [SUPPRIME] = @supprime, [SUPPRIME_USINE] = @suppUsine, [AR_Design] = @design, [FA_CodeFamille] = @famille, Code_douanier = @codeDouanier "; cmd.Parameters.AddWithValue("@sommeil", sommeil); cmd.Parameters.AddWithValue("@supprime", supp); cmd.Parameters.AddWithValue("@suppUsine", suppUsine); cmd.Parameters.AddWithValue("@design", designation); cmd.Parameters.AddWithValue("@famille", famille); cmd.Parameters.AddWithValue("@codeDouanier", codeDouanier); if (isPrincipal) { cmd.CommandText += @", [AR_PrixAch] = ROUND(@arPrixAch, 2), [AR_Coef] = @arCoef, [AR_PrixVen] = ROUND(@arPrixVen, 2), [AR_PoidsNet] = @poids, [AR_UnitePoids] = @unitePoids, [AR_CodeBarre] = @arCodeBarre, [AR_UniteVen] = (SELECT cbMarq FROM P_UNITE WHERE U_Intitule = @uniteVen) "; cmd.Parameters.AddWithValue("@arPrixAch", nvPxNetAchat); cmd.Parameters.AddWithValue("@arCoef", arCoef); cmd.Parameters.AddWithValue("@arPrixVen", nvPxVente); cmd.Parameters.AddWithValue("@poids", arPoidsNet); cmd.Parameters.AddWithValue("@unitePoids", unitePoids); cmd.Parameters.AddWithValue("@arCodeBarre", isGammeOrCond ? string.Empty : gencodArt); cmd.Parameters.AddWithValue("@uniteVen", uniteVen); } cmd.CommandText += " WHERE AR_Ref = @arRef"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.ExecuteNonQuery(); } #endregion #region F_ARTFOURNISS using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = @"UPDATE F_ARTFOURNISS SET [AF_RefFourniss] = @refFourn, [AF_PrixAch] = @afPrixAch, [AF_Remise] = @afRemise, [AF_Conversion] = @conv, [AF_ConvDiv] = @convDiv, [AF_CodeBarre] = @afCodeBarre, [AF_Colisage] = @afColisage, [AF_QteMini] = @afQteMin, [AF_Unite] = (SELECT cbMarq FROM P_UNITE WHERE U_Intitule = @afUnite) WHERE [AR_Ref] = @arRef AND [CT_Num] = @ctNum;"; cmd.Parameters.AddWithValue("@refFourn", refFourn ?? string.Empty); cmd.Parameters.AddWithValue("@afPrixAch", nvPxFourn); cmd.Parameters.AddWithValue("@afRemise", afRemise); cmd.Parameters.AddWithValue("@conv", afConv); cmd.Parameters.AddWithValue("@convDiv", afConvDiv); cmd.Parameters.AddWithValue("@afCodeBarre", gencodFourn ?? string.Empty); cmd.Parameters.AddWithValue("@afColisage", afColisage); cmd.Parameters.AddWithValue("@afQteMin", afQteMin); cmd.Parameters.AddWithValue("@afUnite", afUnite); cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@ctNum", ctNum); cmd.ExecuteNonQuery(); } // Set principal if (isPrincipal) { using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_ARTFOURNISS SET [AF_Principal] = 0 WHERE [AR_Ref] = @arRef;"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE F_ARTFOURNISS SET [AF_Principal] = 1 WHERE [AR_Ref] = @arRef AND [CT_Num] = @ctNum;"; cmd.Parameters.AddWithValue("@ctNum", ctNum); cmd.ExecuteNonQuery(); } } #endregion #region DELETE F_TARIFCOND, F_TARIFGAM & F_ARTCLIENT if (isPrincipal) { using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.CommandText = "DELETE FROM F_TARIFCOND WHERE AR_Ref = @arRef"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM F_TARIFGAM WHERE AR_Ref = @arRef"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM F_ARTCLIENT WHERE AR_Ref = @arRef"; cmd.ExecuteNonQuery(); } } #endregion #region F_ARTCLIENT if (isPrincipal) { double remise; for (int cat = 0; cat < 14; cat++) { using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.Parameters.AddWithValue("@arRef", arRef); switch (cat) { case 0: cmd.CommandText = "INSERT INTO F_ARTCLIENT(AR_Ref, AC_Categorie, AC_PrixVen, AC_PrixTTC) VALUES (@arRef, 1, @acPrixVen, 1)"; cmd.Parameters.AddWithValue("@acPrixVen", nvPxTTC); cmd.ExecuteNonQuery(); break; case 6: cmd.CommandText = "INSERT INTO F_ARTCLIENT(AR_Ref, AC_Categorie, AC_Coef) VALUES (@arRef, 7, 1.1)"; cmd.ExecuteNonQuery(); break; case 13: cmd.CommandText = "INSERT INTO F_ARTCLIENT(AR_Ref, AC_Categorie, AC_Coef) VALUES (@arRef, 14, 1)"; cmd.ExecuteNonQuery(); break; default: remise = row.Range.Columns[tableArticle.ListColumns[$"REMISE CAT {cat}"].Index].value ?? 0; if (remise > 0 || isGammeOrCond) { cmd.CommandText = "INSERT INTO F_ARTCLIENT(AR_Ref, AC_Categorie, AC_Remise) VALUES (@arRef, @acCat, @remise)"; cmd.Parameters.AddWithValue("@acCat", cat + 1); cmd.Parameters.AddWithValue("@remise", remise); cmd.ExecuteNonQuery(); } break; } } } } #endregion #region ECO TAXE // Supprime d'abord les eco-taxes using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; // TODO Centraliser le listing des eco-taxes cmd.CommandText = "DELETE FROM F_NOMENCLAT WHERE AR_Ref = @arRef AND NO_RefDet IN('ECO-TAXE','ECO_TAXE_MOBILIER','TGAP','TGAP_2')"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.ExecuteNonQuery(); if (ecoTaxe != string.Empty) { cmd.CommandText = @"INSERT INTO F_NOMENCLAT(AR_Ref, NO_RefDet, NO_Qte, AG_No1, AG_No2, NO_Type, NO_Repartition, NO_Operation, NO_Commentaire, DE_No, NO_Ordre, AG_No1Comp, AG_No2Comp, NO_SousTraitance) VALUES (@arRef,@ecoTaxe,@qte,0,0,1,0,'','',0,ISNULL((SELECT MAX(NO_Ordre) FROM F_NOMENCLAT WHERE AR_Ref = @arRef), 0)+1,0,0,0)"; cmd.Parameters.AddWithValue("@ecoTaxe", ecoTaxe); cmd.Parameters.AddWithValue("@qte", ecoTaxeQt); cmd.ExecuteNonQuery(); } } #endregion #region CLEAR EAN if (isCondPrinc) { // Efface le EAN de la fiche article (sera deplacé dans le conditionnement principal) using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_ARTICLE SET AR_CodeBarre = NULL WHERE AR_Ref = @arRef"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.ExecuteNonQuery(); } } #endregion } #region GAMME if (isGamme) { // Efface le code barre fournisseur car deplacé dans chaque tarif gamme // Ajoute une ref fourn de base commune à tous les articles de la gamme using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_ARTFOURNISS SET AF_RefFourniss = @refFournBase, AF_CodeBarre = '' WHERE AR_Ref = @arRef AND CT_Num = @ctNum"; cmd.Parameters.AddWithValue("@refFournBase", refFournBase); cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@ctNum", ctNum); cmd.ExecuteNonQuery(); } // F_ARTGAMME using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_ARTGAMME SET EG_Enumere = @egEnum WHERE AR_Ref = @arRef AND AG_No = @agNo"; cmd.Parameters.AddWithValue("@egEnum", gamme1); cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@agNo", ag1); cmd.ExecuteNonQuery(); if (ag2 > 0) { cmd.Parameters["@egEnum"].Value = gamme2; cmd.Parameters["@agNo"].Value = ag2; cmd.ExecuteNonQuery(); } } // F_ARTENUMREF if (isPrincipal) { using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_ARTENUMREF SET AE_Ref = @aeRef, AE_PrixAch = @aePxAch, AE_CodeBarre = @aeCodeBarre WHERE AR_Ref = @arRef AND AG_No1 = @ag1 AND AG_No2 = @ag2"; cmd.Parameters.AddWithValue("@aeRef", refMag); cmd.Parameters.AddWithValue("@aePxAch", nvPxAch); cmd.Parameters.AddWithValue("@aeCodeBarre", gencodArt); cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@ag1", ag1); cmd.Parameters.AddWithValue("@ag2", ag2); cmd.ExecuteNonQuery(); } } // F_TARIFGAM (Tarif fournisseur) using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = @"INSERT INTO F_TARIFGAM(AR_Ref, TG_RefCF, AG_No1, AG_No2, TG_Prix, TG_Ref, TG_CodeBarre) VALUES (@arRef,@ctNum,@ag1,@ag2,@nvPxFourn,@refFourn,@gencodFourn)"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@ctNum", ctNum); cmd.Parameters.AddWithValue("@ag1", ag1); cmd.Parameters.AddWithValue("@ag2", ag2); cmd.Parameters.AddWithValue("@nvPxFourn", nvPxFourn); cmd.Parameters.AddWithValue("@refFourn", refFourn); cmd.Parameters.AddWithValue("@gencodFourn", ((object)gencodFourn) ?? DBNull.Value); cmd.ExecuteNonQuery(); } // F_TARIFGAM (Tarif client) if (isPrincipal) { // Attention! Ici on reference la cat tarif par TG_RefCF // ex a01 => AC_Categorie 0 => Tarif TTC // ex a02 => AC_Categorie 1 => Tarif cat 1 string tgRefCF; for (int i = 1; i < 15; i++) { tgRefCF = $"a{i.ToString().PadLeft(2, '0')}"; using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = @"INSERT INTO F_TARIFGAM(AR_Ref, TG_RefCF, AG_No1, AG_No2, TG_Prix, TG_Ref, TG_CodeBarre) VALUES (@arRef,@tgRefCF,@ag1,@ag2,@prix,'','')"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@tgRefCF", tgRefCF); cmd.Parameters.AddWithValue("@ag1", ag1); cmd.Parameters.AddWithValue("@ag2", ag2); switch (i) { case 1: // Tarif TTC cmd.Parameters.AddWithValue("@prix", nvPxTTC); break; case 7: // Tarif 6 cmd.Parameters.AddWithValue("@prix", nvPxNetAchat * 1.1); break; case 14: // Tarif 13 prix coutant cmd.Parameters.AddWithValue("@prix", nvPxNetAchat); break; default: cmd.Parameters.AddWithValue("@prix", nvPxVente); break; } cmd.ExecuteNonQuery(); } } } } #endregion #region CONDITIONNEMENT if (isCond) { using (var cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "UPDATE F_CONDITION SET CO_CodeBarre = '' WHERE CO_CodeBarre = @gencodArt AND CO_No <> @coNo"; cmd.Parameters.AddWithValue("@gencodArt", gencodArt); cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@coNo", coNo); cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE F_CONDITION SET EC_Enumere = @enumCond, EC_Quantite = @condQt, CO_CodeBarre = @gencodArt WHERE AR_Ref = @arRef AND CO_No = @coNo"; cmd.Parameters.AddWithValue("@enumCond", enumCond); cmd.Parameters.AddWithValue("@condQt", condQt); cmd.ExecuteNonQuery(); } if (isPrincipal) { // Attention! Ici on reference la cat tarif par tcRefCF // ex a01 => AC_Categorie 0 => Tarif TTC // ex a02 => AC_Categorie 1 => Tarif cat 1 string tcRefCF; for (int i = 1; i < 15; i++) { tcRefCF = $"a{i.ToString().PadLeft(2, '0')}"; using (SqlCommand cmd = cnx.CreateCommand()) { cmd.Transaction = transaction; cmd.CommandText = "INSERT INTO F_TARIFCOND (AR_Ref, TC_RefCF, CO_No, TC_Prix) VALUES (@arRef, @tcRefCF, @coNo, @prix)"; cmd.Parameters.AddWithValue("@arRef", arRef); cmd.Parameters.AddWithValue("@tcRefCF", tcRefCF); cmd.Parameters.AddWithValue("@coNo", coNo); switch (i) { case 1: // Tarif TTC cmd.Parameters.AddWithValue("@prix", nvPxTTC); break; case 7: // Tarif 6 cmd.Parameters.AddWithValue("@prix", nvPxNetAchat * 1.1); break; case 14: // Tarif 13 prix coutant cmd.Parameters.AddWithValue("@prix", nvPxNetAchat); break; default: cmd.Parameters.AddWithValue("@prix", nvPxVente); break; } cmd.ExecuteNonQuery(); } } } } #endregion transaction.Commit(); return("OK"); } catch (Exception ex) { try { transaction.Rollback(); return(ex.ToString()); } catch (Exception ex2) { return(ex2.ToString()); } } } } catch (Exception e) { return(e.ToString()); } }