public static void Translation(this LookUpEdit lokMain) { string fName = ""; try { fName = lokMain.FindForm().Name; } catch { } if (!string.IsNullOrEmpty(fName) && lokMain != null && lokMain.Properties.Columns.Count > 0) { //db = new aModel(); //List<xMsgDictionary> lstAdd = new List<xMsgDictionary>(); //foreach (LookUpColumnInfo col in lokMain.Properties.Columns) //{ // string mName = string.Format("{0}_{1}", lokMain.Name, col.FieldName); // var myTrans = db.xMsgDictionaries.FirstOrDefault<xMsgDictionary>(n => n.FormName.Equals(fName) && n.MsgName.Equals(mName)); // if (myTrans == null) // { // lstAdd.Add(myTrans = new xMsgDictionary() // { // FormName = fName, // MsgName = mName, // VN = col.Caption, // EN = col.FieldName.AutoSpace() // }); // } // col.Caption = myTrans.GetStringByName(curCulture); //} //if (lstAdd != null && lstAdd.Count() > 0) //{ // try // { // db.xMsgDictionaries.AddRange(lstAdd); // db.SaveChanges(); // } // catch { } //} } }
public static void FormatColumnLookUpEdit(this LookUpEdit lokMain, string fName = "") { if (string.IsNullOrEmpty(fName)) { try { fName = lokMain.FindForm().Name; } catch { } } if (string.IsNullOrEmpty(fName) || lokMain.Properties.Columns.Count == 0 || !lokMain.Properties.ShowHeader) { return; } //db = new aModel(); //List<xDisplay> lstAdd = new List<xDisplay>(); //bool addCol = false; //foreach (LookUpColumnInfo col in lokMain.Properties.Columns) //{ // addCol = false; // xDisplay myDisplay = null; // try // { // myDisplay = db.xDisplays.FirstOrDefault<xDisplay>(n => n.ParentName.Equals(fName) && n.Group.Equals(lokMain.Name) && n.ColumnName.Equals(col.FieldName)); // addCol = (myDisplay == null); // } // catch { addCol = true; } // finally // { // if (addCol && lokMain.Properties.DataSource != null) // { // myDisplay = new xDisplay(); // myDisplay.ParentName = fName; // myDisplay.Group = lokMain.Name; // myDisplay.ColumnName = col.FieldName; // myDisplay.FieldName = col.FieldName; // myDisplay.Showing = col.Visible; // string cType = "None"; // string cAlign = "Default"; // if (col.FormatType == FormatType.DateTime) // { // cType = "DateTime"; cAlign = "Center"; // } // else if (col.FormatType == FormatType.Numeric) // { // cType = "Numeric"; cAlign = "Far"; // } // else // { // cType = "Custom"; cAlign = "Near"; // } // myDisplay.Type = cType; // myDisplay.TextAlign = cAlign; // myDisplay.EnableEdit = false; // lstAdd.Add(myDisplay); // } // else if (myDisplay == null) // myDisplay = db.xDisplays.FirstOrDefault<xDisplay>(hts => hts.ParentName.Equals(fName) && hts.Group.Equals(lokMain.Name) && hts.ColumnName.Equals(col.FieldName)); // if (myDisplay != null) // { // col.Visible = myDisplay.Showing; // col.FieldName = myDisplay.FieldName; // if (myDisplay.Type != null) // { // if (lokMain.Properties.DataSource != null) // lokMain.Properties.AppearanceDropDownHeader.ForeColor = MyColor.GridForeHeader; // col.FormatType = (FormatType)Enum.Parse(typeof(FormatType), myDisplay.Type); // col.Alignment = (HorzAlignment)Enum.Parse(typeof(HorzAlignment), myDisplay.TextAlign); // if (myDisplay.Type.Equals("Numeric") && curDecimalFormat != null && string.IsNullOrEmpty(col.FormatString)) // col.FormatString = curDecimalFormat; // else if (myDisplay.Type.Equals("DateTime") && curDateFormat != null && string.IsNullOrEmpty(col.FormatString)) // col.FormatString = curDateFormat; // } // } // } //} //if (lstAdd != null && lstAdd.Count > 0) //{ // try // { // db = new aModel(); // db.xDisplays.AddRange(lstAdd); // db.SaveChanges(); // } // catch { } //} }