public Waybill_VM(int?id_object, int id_table) { this.id_object = id_object; waybill_rec = new Waybill_M(id_object); // Для WinForms cntrl1 = new System.Windows.Forms.UserControl(); elementHost1 = new System.Windows.Forms.Integration.ElementHost(); elementHost1.Dock = System.Windows.Forms.DockStyle.Fill; elementHost1.Location = new System.Drawing.Point(0, 0); elementHost1.Name = "elementHost1"; //elementHost1.Child = new Waybill_V() { DataContext = this }; cntrl1.Controls.Add(elementHost1); cntrl1.Load += cntrl1_Load; }
public static void Load_Waybill_Item(ref Waybill_M modelka) { //Waybill_M modelka = new Waybill_M(); if (modelka.Gid == null) { return; } int id_object = (int)modelka.Gid; using (ISQLCommand sqlqry = MainPluginClass.App.SqlWork()) { try { sqlqry.sql = String.Format("SELECT * FROM autobase.waybills WHERE gid = {0}", id_object); if (sqlqry.ExecuteReader() && sqlqry.CanRead()) { modelka.Gid = sqlqry.GetValue <int>("gid"); modelka.Doc_date = sqlqry.GetValue("doc_date") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("doc_date"); modelka.Doc_no = sqlqry.GetValue("doc_no") == null ? "" : sqlqry.GetValue <String>("doc_no"); modelka.Car_id = sqlqry.GetValue <int>("car_id"); modelka.Trailer_id = sqlqry.GetValue <int?>("trailer_id"); modelka.Automaster_id = sqlqry.GetValue <int?>("automaster_id"); modelka.Date_out_plan = sqlqry.GetValue("date_out_plan") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("date_out_plan"); modelka.Date_out_fact = sqlqry.GetValue("date_out_fact") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("date_out_fact"); modelka.Date_in_plan = sqlqry.GetValue("date_in_plan") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("date_in_plan"); modelka.Date_in_fact = sqlqry.GetValue("date_in_fact") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("date_in_fact"); modelka.Driver_id = sqlqry.GetValue <int?>("driver_id"); modelka.Work_regime_id = sqlqry.GetValue <int?>("work_regime_id"); modelka.Motorcade = sqlqry.GetValue <int?>("motorcade"); modelka.Brigade = sqlqry.GetValue <int?>("brigade"); modelka.Route_id = sqlqry.GetValue <int?>("route_id"); modelka.Work_type_id = sqlqry.GetValue <int?>("work_type_id"); modelka.Cargo_type_id = sqlqry.GetValue <int?>("cargo_type_id"); modelka.Ttd_count = sqlqry.GetValue <int?>("ttd_count"); modelka.Trip_count = sqlqry.GetValue <int?>("trip_count"); modelka.Road_type_id = sqlqry.GetValue <int?>("road_type_id"); modelka.Km_begin = sqlqry.GetValue <decimal?>("km_begin"); modelka.Km_end = sqlqry.GetValue <decimal?>("km_end"); modelka.Km_run = sqlqry.GetValue <decimal?>("km_run"); modelka.Km_run_glonass = sqlqry.GetValue <decimal?>("km_run_glonass"); modelka.Mh_begin = sqlqry.GetValue <decimal?>("mh_begin"); modelka.Mh_end = sqlqry.GetValue <decimal?>("mh_end"); modelka.Mh_run = sqlqry.GetValue <decimal?>("mh_run"); modelka.Mh_run_glonass = sqlqry.GetValue <decimal?>("mh_run_glonass"); modelka.Mh_ob_begin = sqlqry.GetValue <decimal?>("mh_ob_begin"); modelka.Mh_ob_end = sqlqry.GetValue <decimal?>("mh_ob_end"); modelka.Mh_ob_run = sqlqry.GetValue <decimal?>("mh_ob_run"); modelka.Mh_ob_run_glonass = sqlqry.GetValue <decimal?>("mh_ob_run_glonass"); modelka.Fuel_mark_id = sqlqry.GetValue <int?>("fuel_mark_id"); modelka.Fuel_plan = sqlqry.GetValue <decimal?>("fuel_plan"); modelka.Fuel_fact = sqlqry.GetValue <decimal?>("fuel_fact"); modelka.Fuel_fact_glonass = sqlqry.GetValue <decimal?>("fuel_fact_glonass"); modelka.Fuel_begin = sqlqry.GetValue <decimal?>("fuel_begin"); modelka.Fuel_end = sqlqry.GetValue <decimal?>("fuel_end"); modelka.Fuel_begin_glonass = sqlqry.GetValue <decimal?>("fuel_begin_glonass"); modelka.Fuel_end_glonass = sqlqry.GetValue <decimal?>("fuel_end_glonass"); modelka.Fuel_mark2_id = sqlqry.GetValue <int?>("fuel_mark2_id"); modelka.Fuel_plan2 = sqlqry.GetValue <decimal?>("fuel_plan2"); modelka.Fuel_fact2 = sqlqry.GetValue <decimal?>("fuel_fact2"); modelka.Fuel_fact2_glonass = sqlqry.GetValue <decimal?>("fuel_fact2_glonass"); modelka.Fuel_begin2 = sqlqry.GetValue <decimal?>("fuel_begin2"); modelka.Fuel_end2 = sqlqry.GetValue <decimal?>("fuel_end2"); modelka.Fuel_begin2_glonass = sqlqry.GetValue <decimal?>("fuel_begin2_glonass"); modelka.Fuel_end2_glonass = sqlqry.GetValue <decimal?>("fuel_end2_glonass"); modelka.Fuel_card_id = sqlqry.GetValue <int?>("fuel_card_id"); modelka.Fuel_card2_id = sqlqry.GetValue <int?>("fuel_card2_id"); modelka.Calc_fuel_norm = sqlqry.GetValue <decimal?>("calc_fuel_norm"); modelka.Calc_fuel_fact = sqlqry.GetValue <decimal?>("calc_fuel_fact"); modelka.Calc_fuel_delta = sqlqry.GetValue <decimal?>("calc_fuel_delta"); modelka.Calc_fuel_drain = sqlqry.GetValue <int?>("calc_fuel_drain"); modelka.Calc_km_run_delta = sqlqry.GetValue <decimal?>("calc_km_run_delta"); modelka.Calc_mh_run_delta = sqlqry.GetValue <decimal?>("calc_mh_run_delta"); modelka.Pay_work_h = sqlqry.GetValue <int?>("pay_work_h"); modelka.Pay_lunch_h = sqlqry.GetValue <int?>("pay_lunch_h"); modelka.Pay_duty_h = sqlqry.GetValue <int?>("pay_duty_h"); modelka.Pay_repair_h = sqlqry.GetValue <int?>("pay_repair_h"); modelka.Pay_day_h = sqlqry.GetValue <int?>("pay_day_h"); modelka.Pay_night_h = sqlqry.GetValue <int?>("pay_night_h"); modelka.Pay_rate_rh = sqlqry.GetValue <decimal?>("pay_rate_rh"); modelka.Pay_total_r = sqlqry.GetValue <decimal?>("pay_total_r"); modelka.Support_persons = sqlqry.GetValue("support_persons") == null ? "" : sqlqry.GetValue <String>("support_persons"); modelka.Special_note_id = sqlqry.GetValue <int?>("special_note_id"); modelka.Notes = sqlqry.GetValue("notes") == null ? "" : sqlqry.GetValue <String>("notes"); modelka.Createdate = sqlqry.GetValue("createdate") == null ? DateTime.MinValue : sqlqry.GetValue <DateTime>("createdate"); modelka.Secondsave = sqlqry.GetValue <int?>("secondsave"); modelka.User_id = sqlqry.GetValue <int?>("user_id"); modelka.Org_id = sqlqry.GetValue <int?>("org_id"); } sqlqry.Close(); } catch (Exception x) { sqlqry.Close(); throw x; } } }