Ejemplo n.º 1
0
        private void txtValue_LostFocus(object sender, RoutedEventArgs e)
        {
            if (dgProperities.SelectedIndex == -1)
            {
                return;
            }
            DataGridRow      row     = dgProperities.ItemContainerGenerator.ContainerFromIndex(dgProperities.SelectedIndex) as DataGridRow;
            ContentPresenter CP      = dgProperities.Columns[clmPropertyValue.DisplayIndex].GetCellContent(row) as ContentPresenter;
            TextBox          DP      = glb_function.FindVisualChild <TextBox>(CP);
            string           strTest = DP.Text.Trim();

            DP.IsReadOnly = true;

            DP.Text = "";
            clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];

            UpdateRow.clmPropertyValue = strTest;

            UpdateRow.clmRealValue = strTest;

            int iSelectedIndex = dgProperities.SelectedIndex;

            dgProperities.Items[iSelectedIndex] = UpdateRow;
            dgProperities.Items.Refresh();
        }
Ejemplo n.º 2
0
        private void GetDetailData(string strHeaderPkid)
        {
            dgProperities.Items.Clear();
            ConnectionToMySQL cnn    = new ConnectionToMySQL();
            DataTable         dtProp = cnn.GetDataTable("select pkid,control_type,en_name,ar_name,list_id,free_list_name from FORMs_de t " +
                                                        " where t.header_id = " + strHeaderPkid + " order by pkid");
            clsFormDetails newRow;

            for (int i = 0; i < dtProp.Rows.Count; i++)
            {
                newRow = new clsFormDetails();
                newRow.clmDetailPkId     = dtProp.Rows[i]["pkid"].ToString();
                newRow.clmPropertyName   = dtProp.Rows[i]["ar_name"].ToString();
                newRow.clmPropertyValue  = "";
                newRow.clmcontrol_type   = dtProp.Rows[i]["control_type"].ToString();
                newRow.clmlist_id        = dtProp.Rows[i]["list_id"].ToString();
                newRow.clmfree_list_name = dtProp.Rows[i]["free_list_name"].ToString();
                newRow.clmen_name        = dtProp.Rows[i]["en_name"].ToString();

                dgProperities.Items.Add(newRow);
            }
        }
Ejemplo n.º 3
0
        private void dgProperities_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dgvForms.Items.Count > 0)
            {
                if (dgProperities.SelectedIndex >= 0)
                {
                    if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "Enability")
                    {
                        frmlstEditor frm = new frmlstEditor();
                        frm.lstEditor.Items.Add("تفعيل");
                        frm.lstEditor.Items.Add("اغلاق");
                        frm.ShowDialog();



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = frm.lstEditor.Text;
                        if (frm.lstEditor.Text == "تفعيل")
                        {
                            UpdateRow.clmRealValue = "1";
                        }
                        else
                        {
                            UpdateRow.clmRealValue = "0";
                        }
                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }

                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "Visability")
                    {
                        frmlstEditor frm = new frmlstEditor();
                        frm.lstEditor.Items.Add("اظهار");
                        frm.lstEditor.Items.Add("اخفاء");
                        frm.ShowDialog();



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = frm.lstEditor.Text;
                        if (frm.lstEditor.Text == "اظهار")
                        {
                            UpdateRow.clmRealValue = "1";
                        }
                        else
                        {
                            UpdateRow.clmRealValue = "0";
                        }
                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }
                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "Text")
                    {
                        DataGridRow      row = dgProperities.ItemContainerGenerator.ContainerFromIndex(dgProperities.SelectedIndex) as DataGridRow;
                        ContentPresenter CP  = dgProperities.Columns[clmPropertyValue.DisplayIndex].GetCellContent(row) as ContentPresenter;
                        TextBox          DP  = glb_function.FindVisualChild <TextBox>(CP);
                        DP.IsReadOnly = false;
                    }
                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "Free List")
                    {
                        frmlstEditor      frm        = new frmlstEditor();
                        ConnectionToMySQL cnn        = new ConnectionToMySQL();
                        DataTable         dtFreeList = cnn.GetDataTable("select display_member,value_member from free_list " +
                                                                        " where list_name = '" + glb_function.GetCellValue(ref dgProperities, clmFreeListName.DisplayIndex, dgProperities.SelectedIndex) + "'");

                        frm.lstEditor.ItemsSource       = dtFreeList.DefaultView;
                        frm.lstEditor.SelectedValuePath = "value_member";
                        frm.lstEditor.DisplayMemberPath = "display_member";
                        frm.ShowDialog();



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = frm.lstEditor.Text;

                        UpdateRow.clmRealValue = frm.lstEditor.SelectedValue.ToString();

                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }
                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "List")
                    {
                        frmlstEditor      frm         = new frmlstEditor();
                        ConnectionToMySQL cnn         = new ConnectionToMySQL();
                        DataTable         dtListTable = cnn.GetDataTable("select  select_statement from LIST_TYPE t " +
                                                                         " where pkid =  '" + glb_function.GetCellValue(ref dgProperities, clmListId.DisplayIndex, dgProperities.SelectedIndex) + "'");

                        DataTable dtGetList = cnn.GetDataTable(dtListTable.Rows[0][0].ToString());



                        frm.lstEditor.ItemsSource       = dtGetList.DefaultView;
                        frm.lstEditor.SelectedValuePath = "pkid";
                        frm.lstEditor.DisplayMemberPath = "name";
                        frm.ShowDialog();



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = frm.lstEditor.Text;

                        UpdateRow.clmRealValue = frm.lstEditor.SelectedValue.ToString();

                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }
                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "MultiChoices")
                    {
                        frmMultilstEditor frm         = new frmMultilstEditor();
                        ConnectionToMySQL cnn         = new ConnectionToMySQL();
                        DataTable         dtListTable = cnn.GetDataTable("select  select_statement from LIST_TYPE t " +
                                                                         " where pkid =  '" + glb_function.GetCellValue(ref dgProperities, clmListId.DisplayIndex, dgProperities.SelectedIndex) + "'");

                        DataTable dtGetList = cnn.GetDataTable(dtListTable.Rows[0][0].ToString());



                        //frm.lstEditor.ItemsSource = dtGetList.DefaultView;
                        //frm.lstEditor.SelectedValuePath = "pkid".ToUpper();
                        //frm.lstEditor.DisplayMemberPath = "name".ToUpper();
                        frm.myList = new ObservableCollection <frmMultilstEditor.MultiList>();

                        for (int i = 0; i < dtGetList.Rows.Count; i++)
                        {
                            string strText = dtGetList.Rows[i]["name"].ToString();
                            int    iValue  = Convert.ToUInt16(dtGetList.Rows[i]["pkid"].ToString());
                            frm.myList.Add(new frmMultilstEditor.MultiList {
                                TheText = strText, TheValue = iValue
                            });
                        }
                        frm.DataContext = frm;
                        frm.lstEditor.UpdateLayout();

                        if (glb_function.GetCellValue(ref dgProperities, clmRealValue.DisplayIndex, dgProperities.SelectedIndex) != "")
                        {
                            string strMult = glb_function.GetCellValue(ref dgProperities, clmRealValue.DisplayIndex, dgProperities.SelectedIndex);

                            string iindexx = "";

                            while (strMult != "")
                            {
                                iindexx = (strMult.Substring(0, strMult.IndexOf(";")));
                                strMult = strMult.Substring(strMult.IndexOf(";") + 1);

                                for (int i = 0; i < frm.lstEditor.Items.Count; i++)
                                {
                                    frmMultilstEditor.MultiList o = (frmMultilstEditor.MultiList)frm.lstEditor.Items[i];
                                    if (o.TheValue.ToString() == iindexx)
                                    {
                                        o.IsSelected = true;
                                    }
                                }
                            }
                        }


                        frm.ShowDialog();
                        string strPropertyValue = "";
                        string strPropRealValue = "";
                        for (int i = 0; i < frm.lstEditor.Items.Count; i++)
                        {
                            frmMultilstEditor.MultiList o = (frmMultilstEditor.MultiList)frm.lstEditor.Items[i];


                            if (o.IsSelected == true)
                            {
                                strPropertyValue += o.TheText + ";";
                                strPropRealValue += o.TheValue + ";";
                            }
                        }



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = strPropertyValue;

                        UpdateRow.clmRealValue = strPropRealValue;

                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }
                    else if (glb_function.GetCellValue(ref dgProperities, clmcontrol_type.DisplayIndex, dgProperities.SelectedIndex) == "Free MultiChoices")
                    {
                        frmMultilstEditor frm        = new frmMultilstEditor();
                        ConnectionToMySQL cnn        = new ConnectionToMySQL();
                        DataTable         dtFreeList = cnn.GetDataTable("select display_member,value_member from free_list " +
                                                                        " where list_name = '" + glb_function.GetCellValue(ref dgProperities, clmFreeListName.DisplayIndex, dgProperities.SelectedIndex) + "'");


                        frm.myList = new ObservableCollection <frmMultilstEditor.MultiList>();

                        for (int i = 0; i < dtFreeList.Rows.Count; i++)
                        {
                            string strText = dtFreeList.Rows[i]["name"].ToString();
                            int    iValue  = Convert.ToUInt16(dtFreeList.Rows[i]["pkid"].ToString());
                            frm.myList.Add(new frmMultilstEditor.MultiList {
                                TheText = strText, TheValue = iValue
                            });
                        }
                        frm.DataContext = frm;
                        frm.lstEditor.UpdateLayout();

                        if (glb_function.GetCellValue(ref dgProperities, clmRealValue.DisplayIndex, dgProperities.SelectedIndex) != "")
                        {
                            string strMult = glb_function.GetCellValue(ref dgProperities, clmRealValue.DisplayIndex, dgProperities.SelectedIndex);

                            string iindexx = "";

                            while (strMult != "")
                            {
                                iindexx = (strMult.Substring(0, strMult.IndexOf(";")));
                                strMult = strMult.Substring(strMult.IndexOf(";") + 1);

                                for (int i = 0; i < frm.lstEditor.Items.Count; i++)
                                {
                                    frmMultilstEditor.MultiList o = (frmMultilstEditor.MultiList)frm.lstEditor.Items[i];
                                    if (o.TheValue.ToString() == iindexx)
                                    {
                                        o.IsSelected = true;
                                    }
                                }
                            }
                        }


                        frm.ShowDialog();
                        string strPropertyValue = "";
                        string strPropRealValue = "";
                        for (int i = 0; i < frm.lstEditor.Items.Count; i++)
                        {
                            frmMultilstEditor.MultiList o = (frmMultilstEditor.MultiList)frm.lstEditor.Items[i];


                            if (o.IsSelected == true)
                            {
                                strPropertyValue += o.TheText + ";";
                                strPropRealValue += o.TheValue + ";";
                            }
                        }



                        clsFormDetails UpdateRow = (clsFormDetails)dgProperities.Items[dgProperities.SelectedIndex];
                        UpdateRow.clmPropertyValue = strPropertyValue;

                        UpdateRow.clmRealValue = strPropRealValue;

                        int iSelectedIndex = dgProperities.SelectedIndex;

                        dgProperities.Items[iSelectedIndex] = UpdateRow;
                        dgProperities.Items.Refresh();
                    }
                }
            }
        }