Esempio n. 1
0
        private void delFile(int Type)
        {
            Model.File objOld = null;
            if (Type == 1)
            {
                foreach (var item in gvFileOpen.GetSelectedRows())
                {
                    string file = (string)gvFileOpen.GetRowCellValue(item, gridColumn1);
                    objOld = currentSetting.FileOpen.Where(m => m.FileApp.ToLower().Equals(file.ToLower())).SingleOrDefault();
                    if (objOld != null)
                    {
                        currentSetting.FileOpen.Remove(objOld);
                    }
                }
                gcFileOpen.DataSource = currentSetting.FileOpen;
                gcFileOpen.RefreshDataSource();

                gvFileOpen.ClearSelection();
                gvFileOpen.SelectRow(gvFileOpen.FocusedRowHandle);
            }
            else
            {
                foreach (var item in gvFileClose.GetSelectedRows())
                {
                    string file = (string)gvFileClose.GetRowCellValue(item, gridColumn1);
                    objOld = currentSetting.FileClose.Where(m => m.FileApp.ToLower().Equals(file.ToLower())).SingleOrDefault();
                    if (objOld != null)
                    {
                        currentSetting.FileClose.Remove(objOld);
                    }
                }
                gcFileClose.DataSource = currentSetting.FileClose;
                gcFileClose.RefreshDataSource();

                gvFileClose.ClearSelection();
                gvFileClose.SelectRow(gvFileClose.FocusedRowHandle);
            }
        }
Esempio n. 2
0
        private void addFile(int Type, string message)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                try
                {
                    dlg.Title  = "Buka file Exe";
                    dlg.Filter = "File Exe|*.exe";
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        List <String> Parameter = new List <string>();
                        string        Temp      = XtraInputBox.Show(message, "Isikan argument/parameter dengan separator koma", "");
                        if (Temp.Length != 0)
                        {
                            Parameter = Temp.Split(new char[] { ',' }).ToList();
                        }

                        if (Type == 1)
                        {
                            Model.File ObjOld = currentSetting.FileOpen.Where(m => m.FileApp.ToLower().Equals(dlg.FileName.ToLower())).SingleOrDefault();
                            if (ObjOld != null)
                            {
                                currentSetting.FileOpen.Remove(ObjOld);
                            }
                            Model.File ObjNew = new Model.File {
                                FileApp = dlg.FileName, Params = Parameter
                            };
                            currentSetting.FileOpen.Add(ObjNew);
                            gcFileOpen.DataSource = currentSetting.FileOpen;
                            gcFileOpen.RefreshDataSource();

                            gvFileOpen.ClearSelection();
                            gvFileOpen.FocusedRowHandle = gvFileOpen.LocateByDisplayText(0, gridColumn1, dlg.FileName);
                            gvFileOpen.SelectRow(gvFileOpen.FocusedRowHandle);
                        }
                        else
                        {
                            Model.File ObjOld = currentSetting.FileClose.Where(m => m.FileApp.ToLower().Equals(dlg.FileName.ToLower())).SingleOrDefault();
                            if (ObjOld != null)
                            {
                                currentSetting.FileClose.Remove(ObjOld);
                            }
                            Model.File ObjNew = new Model.File {
                                FileApp = dlg.FileName, Params = Parameter
                            };
                            currentSetting.FileClose.Add(ObjNew);
                            gcFileClose.DataSource = currentSetting.FileClose;
                            gcFileClose.RefreshDataSource();

                            gvFileClose.ClearSelection();
                            gvFileClose.FocusedRowHandle = gvFileClose.LocateByDisplayText(0, colFileApp, dlg.FileName);
                            gvFileClose.SelectRow(gvFileClose.FocusedRowHandle);
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message);
                }
            }
        }