public static string PrintLine(this ClientCodeRealtion cc) { if (cc == null) { return(""); } return(String.Format("{0,-35:D}{1,-20}{2,-10}{3:N}" + Environment.NewLine, cc.AddedClientCodeRelationDate, cc.Description, cc.Code, cc.Amount)); }
public static IEnumerable <ClientCodeRealtion> ConvertGridDataDbEnumerableObject(this DataGrid clientCodeDataGrid, int clientId) { var selectedList = new List <ClientCodeRealtion>(); var cac = ClientsAppContext.GetContextInstance(); ItemCollection items = clientCodeDataGrid.Items; for (int i = 0; i < items.Count; i++) { var it = items[i]; ClientCodeRealtion temp = it as ClientCodeRealtion; if (temp == null) { break; } if (temp.ClientID == null) { temp.ClientID = clientId; } var code = cac.GetAllCodes().Single(a => string.Equals(temp.Description, a.Description)); temp.CodeID = code.ID; var mycheckbox = clientCodeDataGrid.Columns[4].GetCellContent(it) as CheckBox; if (mycheckbox.IsChecked.Value) { temp.ToDelete = true; } selectedList.Add(temp); } cac.RemoveAllClientCodes(clientId); foreach (var ccrs in selectedList) { if (!ccrs.ToDelete) { var temmpClientCode = new ClientCode() { client_ID = ccrs.ClientID, code_ID = ccrs.CodeID, CreatedTime = ccrs.AddedClientCodeRelationDate, }; cac.AddClientCode(temmpClientCode); } } selectedList.RemoveAll(a => a.ToDelete); return(selectedList); }
public static string PrintItemCollection(this ItemCollection cc) { string result = ""; foreach (var it in cc) { ClientCodeRealtion temp = it as ClientCodeRealtion; result += temp.PrintLine(); } return(result); }
private void clientCodesRelationGRD_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { int description_column_index = 1; DataGrid dg = sender as DataGrid; if (e.Column.DisplayIndex == description_column_index) { ClientCodeRealtion ccr = dg.SelectedItem as ClientCodeRealtion; Code code = cac.GetAllCodes().Single(a => String.Equals(ccr.Description, a.Description)); dg.GetCell(e.Row.GetIndex(), 2).Content = code.Code1; dg.GetCell(e.Row.GetIndex(), 3).Content = code.Amount; } }
private void clientCodesRelationGRD_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { DataGrid dg = sender as DataGrid; ClientCodeRealtion clientCode = dg.SelectedItem as ClientCodeRealtion; Client tempclient = FirstLastDofAFrid.SelectedItem as Client; if (clientCode.ClientID == null) { clientCode.ClientID = tempclient.ID; } clientCodeRelHelper.Insert(clientCode, "New Code "); }
public static void Insert(this ClientCodeRealtion cc) { ClientsAppContext cac = ClientsAppContext.GetContextInstance(); Code code = cac.GetAllCodes().Single(a => string.Equals(cc.Description, a.Description)); ClientCode clientcode = new ClientCode() { client_ID = cc.ClientID, code_ID = code.ID, Description = cc.Description, CreatedTime = DateTime.Now, }; cac.AddClientCode(clientcode); }