Exemplo n.º 1
0
        //Загрузка операторов из файла
        public static Operator[] LoadOperators(string address)
        {
            IniFile settings = new IniFile(Directory.GetCurrentDirectory() + "\\settings\\" + address + ".ini");
            int count;
            count = int.Parse(settings.IniReadValue("operators", "count"));

            Operator[] op = new Operator[count];
            for (int i = 0; i < count; i++)
            {
                op[i] = new Operator();
                op[i].Name = settings.IniReadValue("op" + i, "name");
                op[i].Code = int.Parse(settings.IniReadValue("op" + i, "code"));
                op[i].ID = int.Parse(settings.IniReadValue("op" + i, "id"));
                op[i].CashPwd = settings.IniReadValue("op" + i, "edCashPsw");
                op[i].NotActive = bool.Parse(settings.IniReadValue("op" + i, "chNotActive"));
                op[i].Mask = int.Parse(settings.IniReadValue("op" + i, "mask"));
                op[i].HasPassword = bool.Parse(settings.IniReadValue("op" + i, "HasPassword"));
                op[i].IsSec = bool.Parse(settings.IniReadValue("op" + i, "IsSecurity"));
                op[i].Password = "";
                try
                {
                    op[i].ForDelete = bool.Parse(settings.IniReadValue("op" + i, "ForDelete"));
                }
                catch
                {
                    op[i].ForDelete = false;
                }
                try
                {
                    op[i].Updated = bool.Parse(settings.IniReadValue("op" + i, "Updated"));
                }
                catch
                {
                    op[i].Updated = false;
                }
                try
                {
                    op[i].New = bool.Parse(settings.IniReadValue("op" + i, "New"));
                }
                catch
                {
                    op[i].New = false;
                }
            }
            return op;
        }
Exemplo n.º 2
0
 //Сохранение операторов в файл
 public static void SaveOperators(string address, Operator[] Op)
 {
     IniFile settings = new IniFile(Directory.GetCurrentDirectory() + "\\settings\\" + address + ".ini");
     int count = Op.Length;
     for (int i = 0; i < count; i++)
     {
         settings.IniWriteValue("op" + i, "name", Op[i].Name);
         settings.IniWriteValue("op" + i, "id", Op[i].ID.ToString());
         settings.IniWriteValue("op" + i, "IsSecurity", Op[i].IsSec.ToString());
         if (Op[i].CashPwd == "")
         {
             Op[i].CashPwd = "0";
         }
         settings.IniWriteValue("op" + i, "edCashPsw", Op[i].CashPwd);
         settings.IniWriteValue("op" + i, "chNotActive", Op[i].NotActive.ToString());
         settings.IniWriteValue("op" + i, "mask", Op[i].Mask.ToString());
         if (Op[i].NewPassword)
         {
             settings.IniWriteValue("op" + i, "password", Op[i].Password);
             settings.IniWriteValue("op" + i, "NewPassword", Op[i].NewPassword.ToString());
         }
         else
         {
             settings.IniWriteValue("op" + i, "NewPassword", Op[i].NewPassword.ToString());
         }
         if (!Op[i].New)
         {
             settings.IniWriteValue("op" + i, "code", Op[i].Code.ToString());
             if (Op[i].ForDelete)
             {
                 settings.IniWriteValue("op" + i, "New", "False");
                 settings.IniWriteValue("op" + i, "ForDelete", "True");
                 settings.IniWriteValue("op" + i, "Updated", "False");
             }
             else
             {
                 settings.IniWriteValue("op" + i, "New", "False");
                 settings.IniWriteValue("op" + i, "ForDelete", "False");
                 settings.IniWriteValue("op" + i, "Updated", "True");
             }
         }
         if (Op[i].New)
         {
             settings.IniWriteValue("op" + i, "New", "True");
             settings.IniWriteValue("op" + i, "ForDelete", "False");
             settings.IniWriteValue("op" + i, "Updated", "False");
         }
     }
     settings.IniWriteValue("operators", "count", count.ToString());
 }
Exemplo n.º 3
0
 //Добавление нового оператора
 public static Operator[] addOperator(Operator[] op, string Name, string Password)
 {
     Operator[] temp;
     try
     {
         temp = op;
         Array.Resize(ref temp, temp.Length + 1);
         temp[op.Length] = new Operator();
         temp[op.Length].Name = Name;
         temp[op.Length].Password = Password;
         op = temp;
         return op;
     }
     catch
     {
         temp = new Operator[1];
         temp[temp.Length - 1] = new Operator();
         temp[temp.Length - 1].Name = Name;
         temp[temp.Length - 1].Password = Password;
         op = temp;
         return op;
     }
 }