private void SearchGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            // Click Grid
            try
            {
                if (SearchGrid.GetFocusedRowCellValue("id") != null)
                {
                    String _id   = SearchGrid.GetFocusedRowCellValue("id").ToString().Trim();
                    String _name = SearchGrid.GetFocusedRowCellValue("name").ToString().Trim();

                    if (_id != "" && _name != "")
                    {
                        Select_EntityName = _name;
                        Select_EntityID   = _id;

                        _lookup.LogicalName = _Entity;
                        _lookup.Name        = _name;
                        _lookup.Id          = new Guid(_id);

                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnAccept_Click: " + ex.Message, rm.GetString("ErrorNotification"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
 private void SearchGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     // Klick
     try
     {
         if (SearchGrid.GetFocusedRowCellValue("gcdescription") != null)
         {
             String _desc       = SearchGrid.GetFocusedRowCellValue("gcdescription").ToString().Trim();
             String _entitytype = SearchGrid.GetFocusedRowCellValue("gctype").ToString().Trim();
             if (_desc != "" && _entitytype != "")
             {
                 Selected_EntityType = _entitytype;
                 Selected_ID         = _desc;
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SearchGrid_MouseDoubleClick: " + ex.Message, rm.GetString("ErrorMessage"), MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #3
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SearchGrid.GetFocusedRowCellValue("gcdescription") != null)
                {
                    String _desc       = SearchGrid.GetFocusedRowCellValue("gcdescription").ToString().Trim();
                    String _entitytype = SearchGrid.GetFocusedRowCellValue("gctype").ToString().Trim();
                    if (_desc != "" && _entitytype != "")
                    {
                        Selected_EntityType = _entitytype;
                        Selected_ID         = _desc;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnCreate_Click: " + ex.Message, rm.GetString("ErrorMessage"), MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Create MSCRM
            //if (lv.SelectedItem != null)
            //{
            //    ListViewItem _li = (ListViewItem)lv.SelectedItem;
            //    Int32 _count = 0;

            //    // Iterate selected grid rows
            //    for (int i = 0; i < _parent_tv.SelectedRows.Count; i++)
            //    {
            //        System.Data.DataRowView _drv = (System.Data.DataRowView)_parent_tv.SelectedRows[i];
            //        DataRow _dr = _drv.Row;
            //        String _status = "";

            //        try
            //        {
            //            _status = _dr["status"].ToString().Trim().ToUpper();
            //        } catch
            //        {
            //        }

            //        if (_status == "NOSYNC")
            //        {
            //            // MessageBox.Show("id=" + _dr["id"].ToString());

            //            // MessageBox.Show("GUID=" + _li.Tag.ToString());

            //            Guid gSelectedParent = new Guid(_li.Tag.ToString());
            //            Double dHours = Convert.ToDouble(_dr["dauer"].ToString());

            //            new_timeentry te = new new_timeentry();
            //            te.new_name = _dr["taetigkeit"].ToString();
            //            te.new_description = "";
            //            te.new_annotation = "";

            //            Lookup lParent = new Lookup();
            //            lParent.Value = gSelectedParent;

            //            if (Sync_Entity_Type == "AP")
            //            {
            //                lParent.type = EntityName.new_workpackage.ToString();
            //                te.new_workpackageid = lParent;
            //            }
            //            else if (Sync_Entity_Type == "ANF")
            //            {
            //                lParent.type = EntityName.incident.ToString();
            //                te.new_incidentid = lParent;
            //            }
            //            else if (Sync_Entity_Type == "VC")
            //            {
            //                lParent.type = EntityName.opportunity.ToString();
            //                te.new_opportunityid = lParent;
            //            }

            //            CrmDecimal dDuration = new CrmDecimal();
            //            dDuration.Value = (decimal)dHours;
            //            te.new_durationh = dDuration;

            //            DateTime _dt = Convert.ToDateTime(_dr["datum"].ToString());

            //            CrmDateTime cdt = new CrmDateTime();
            //            cdt.Value = _dt.Month.ToString() + "-" + _dt.Day.ToString() + "-" + _dt.Year.ToString();
            //            te.new_date = cdt;

            //            Lookup lUser = new Lookup();
            //            lUser.Value = new Guid(_dr["mscrmuserid"].ToString());
            //            lUser.type = EntityName.systemuser.ToString();
            //            te.new_executeuserid = lUser;

            //            cdt = new CrmDateTime();
            //            cdt.Value = _dr["beginn"].ToString();
            //            te.new_starttime = cdt;

            //            cdt = new CrmDateTime();
            //            cdt.Value = _dr["ende"].ToString();
            //            te.new_endtime = cdt;

            //            // te.new_duration_measured = _dr["timemeasurements"].ToString();  ??????????????

            //            String _zusartzzeit = _dr["zusatzzeit"].ToString();
            //            String[] _zz = _zusartzzeit.Split(':');
            //            Int32 _zz_hours = Convert.ToInt32(_zz[0]);
            //            Int32 _zz_minutes = Convert.ToInt32(_zz[1]);
            //            Double _zz_duration = _zz_hours + (_zz_minutes / 60.0);

            //            CrmDecimal dDurationAdditional = new CrmDecimal();
            //            dDurationAdditional.Value = (decimal)_zz_duration;
            //            te.new_duration_additional = dDurationAdditional;

            //            try
            //            {
            //                Picklist pBilling = new Picklist();
            //                int iValue = Convert.ToInt16(_dr["mscrmbillingtypeid"].ToString());
            //                if (iValue >= 0)
            //                {
            //                    pBilling.name = (string)_dr["mscrmbillingtype"].ToString();
            //                    pBilling.Value = iValue;
            //                    te.new_billing = pBilling;
            //                }
            //            }
            //            catch (Exception ex)
            //            {
            //            }

            //            Guid teGuid = Guid.Empty;

            //            try
            //            {
            //                CrmService service = CRMManager.GetService();
            //                teGuid = service.Create(te);
            //            }
            //            catch (Exception ex)
            //            {
            //                MessageBox.Show(ex.Message);
            //            }

            //            if (teGuid == Guid.Empty)
            //            {
            //                MessageBox.Show("Record Not Saved");
            //            }
            //            else
            //            {
            //                _dr["status"] = "LINKED";
            //                _dr["mscrmguid"] = teGuid.ToString();
            //                _count++;
            //            }
            //        }
            //    }

            //    if (_count > 0)
            //    {
            //        MessageBox.Show("Es wurden " + _count.ToString() + " Zeiteinträge erfolgreich nach MSCRM übertragen!", "Hinweis", MessageBoxButton.OK, MessageBoxImage.Information);
            //    }

            //    this.Close();
            //}
        }