Example #1
0
        /* Checker callback */
        // not ok
        private void PostDataImportAction()
        {
            /*if (ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles && this.Cheques.Tables.Count != ConfigManager.Instance.CommonConfiguration.PROFILES_Items.Count)
            {
                DataWorkSource.CreateTables(ref Cheque, ref Articles, ref AltBC, ref Cards, ref Cheques);
                this.CreateOrderStructure(this.Cheque);
                foreach (DictionaryEntry de in ConfigManager.Instance.CommonConfiguration.PROFILES_Items)
                {
                    this.CreateOrderStructure(this.Cheques.Tables[de.Key.ToString()]);
                    this.Discount.Add(de.Key, DataWorkShared.GetStandartDiscountInfoStructure2());
                    this.Summa.Add(de.Key, DataWorkShared.GetStandartCalculationInfoStructure2());
                }
            }
            */
            //if (this.Summa.Count != ConfigManager.Instance.CommonConfiguration.PROFILES_Items.Count)
                this.InitChequeInformationStructure();

            //bool notificationIsActive = false;
            bool _fl_updated = false;
            //uiWndUpdateWnd uw = new uiWndUpdateWnd(_fl_onlyUpdate);
            List<string> allProfiles = new List<string>();
            //foreach (DictionaryEntry de in ConfigManager.Instance.CommonConfiguration.PROFILES_Items)
            //    allProfiles.Add(de.Key.ToString());

            foreach (DataTable dt in this.ImportedData.Tables)
            {
                // get profile name and data
                // 0 - data name
                // 1 - profile name
                string[] prData = dt.TableName.Split(new[] { '=' });
                string key = prData[1];

                // add unique profile index
                if (!allProfiles.Contains(key))
                    allProfiles.Add(key);

                switch (prData[0].ToUpper())
                {
                    case "PROD":
                        {
                            //Articles = tables[0].Copy();
                            DataRow[] dRows = Articles.Select("F = " + key);
                            foreach (DataRow dr in dRows)
                                dr.Delete();
                            Articles.Merge(dt);
                            //wasUpdatedAtLeastOneSource = true;
                            _fl_updated = true;
                            break;
                        }
                    case "ALT":
                        {
                            DataRow[] dRows = AltBC.Select("F = " + key);
                            foreach (DataRow dr in dRows)
                                dr.Delete();
                            AltBC.Merge(dt);
                            _fl_updated = true;
                            break;
                        }
                    case "CARD":
                        {
                            Cards.Rows.Clear();
                            Cards.Merge(dt);
                            _fl_updated = true;
                            break;
                        }
                }

            }

            _fl_onlyUpdate = true;
            _fl_subUnitChanged = false;
            _fl_isOk = new Com_SecureRuntime().FullLoader();
            label_uiWndmain_DemoShowArt.Visible = label_uiWndmain_DemoShowChq.Visible = !_fl_isOk;

            if (_fl_updated)
            {
                /* Removing unused rows */
                string cleanupQuery = string.Empty;
                foreach (string existedProfiles in allProfiles)
                {
                    cleanupQuery += " F <> " + existedProfiles + " AND ";
                }
                cleanupQuery = cleanupQuery.Trim(new char[] { ' ', 'A', 'N', 'D' });
                DataRow[] unusedRowsArt = Articles.Select(cleanupQuery);
                DataRow[] unusedRowsAlt = AltBC.Select(cleanupQuery);
                foreach (DataRow dr in unusedRowsArt)
                    dr.Delete();
                foreach (DataRow dr in unusedRowsAlt)
                    dr.Delete();

                if (this.WindowState == FormWindowState.Minimized)
                    this.WindowState = FormWindowState.Normal;
                //this.BringToFront();
                MMessageBoxEx.Show(this.chequeDGV, "Були внесені зміни в базу товарів", Application.ProductName,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            SrchTbox.Select();
            GC.Collect();

            /* device status */
            if (Program.AppPlugins.IsActive(PluginType.FPDriver))
            {
                try
                {
                    bool status = (bool)Program.AppPlugins.GetActive<IFPDriver>().CallFunction("FP_SetCashier", ConfigManager.Instance.CommonConfiguration.APP_PayDesk, UserConfig.UserFpLogin, UserConfig.UserFpPassword, UserConfig.UserID);
                    if (status)
                        DDM_FPStatus.Image = Properties.Resources.ok;
                    else
                        DDM_FPStatus.Image = Properties.Resources.FpNotOk;
                }
                catch { DDM_FPStatus.Image = Properties.Resources.FpNotOk; }
            }
            else
                DDM_FPStatus.Image = Properties.Resources.FpNotOk;
        }
Example #2
0
        private static void ReadCard(string path, ref DataTable dTable, int startupIndex)
        {
            byte err_cnt = 0;

            if (File.Exists(path))
            {
                StreamReader sr = null;
                do
                {
                    try
                    {
                        sr = new StreamReader(path, Encoding.Default);
                        break;
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(100);
                        err_cnt++;
                    }

                } while (err_cnt < 10);

                if (sr == null)
                    return;

                string line = string.Empty;
                DataRow dRow = dTable.NewRow();
                //long index = 0;
                int myrd = 0;
                bool reader = new Com_SecureRuntime().FullLoader();

                string firmId = CoreConst.KEY_DEFAULT_PROFILE_ID;
                if (driver.Config.ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                {
                    string[] fName = Path.GetFileNameWithoutExtension(path).Split(new char[] { '_' });
                    try
                    {
                        firmId = int.Parse(fName[1].Substring(0, 2)).ToString();
                    }
                    catch { }
                }

                while ((line = sr.ReadLine()) != null)
                {
                    if (line == string.Empty)
                        continue;

                    if (!reader && myrd >= 10)
                        break;

                    if (reader && (myrd + 1) % 100 == 0)
                        reader = new Com_SecureRuntime().FullLoader();

                    //dRow["C"] = index++;

                    dRow["F"] = firmId;
                    dRow["CBC"] = line.Substring(0, 20).Trim();//abc
                    dRow["CID"] = line.Substring(20, 10).Trim();//aid
                    dRow["CDISC"] = MathLib.GetDouble(line.Substring(30, 6).Trim());//cdisc
                    try
                    {
                        dRow["CPRICENO"] = int.Parse(line.Substring(36).Trim());//cdisc
                    }
                    catch { dRow["CPRICENO"] = (int)0; }
                    dTable.Rows.Add(dRow);
                    dRow = dTable.NewRow();

                    myrd++;
                }
                sr.Close();
                sr.Dispose();
            }
        }
Example #3
0
        private static void ReadProduct(string path, ref DataTable dTable, int startupIndex)
        {
            byte err_cnt = 0;

            if (File.Exists(path))
            {
                //StreamReader sr = null;
                Stream sr = null;
                do
                {
                    try
                    {
                        //sr = new StreamReader(path, Encoding.Default);
                        sr = new FileStream(path, FileMode.Open);
                        break;
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(100);
                        err_cnt++;
                    }

                } while (err_cnt < 10);

                if (sr == null)
                    return;

                BufferedStream buff = new BufferedStream(sr, 131072);
                StreamReader reader = new StreamReader(buff, Encoding.Default);
                StringReader strRd = new StringReader(reader.ReadToEnd());
                sr.Close();
                sr.Dispose();
                string line = string.Empty;
                DataRow dRow = dTable.NewRow();
                int sc = 0;
                bool isfull = new Com_SecureRuntime().FullLoader();
                dTable.Rows.Clear();

                string firmId = CoreConst.KEY_DEFAULT_PROFILE_ID;
                if (driver.Config.ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                {
                    string[] fName = Path.GetFileNameWithoutExtension(path).Split(new char[] { '_' });
                    try
                    {
                        firmId = int.Parse(fName[1].Substring(0, 2)).ToString();
                    }
                    catch { }
                }

                dTable.Columns["C"].AutoIncrementSeed = startupIndex + 10 * int.Parse(firmId);
                if (dTable.Columns["C"].AutoIncrementSeed == 0)
                    dTable.Columns["C"].AutoIncrementSeed = 1;

                Com_WinApi.OutputDebugString("ReadArtSDF_begin");
                while ((line = strRd.ReadLine()) != null)
                {
                    if (line == string.Empty)
                        continue;

                    if (!isfull && sc >= 10)
                        break;
                    /*
                    if (isfull && (sc + 1) % 100 == 0)
                        isfull = new sgmode.ClassMode().FullLoader();
                    */
                    //dRow["C"] = index++;
                    line = line.Replace("\\\\", "\\");
                    dRow = dTable.NewRow();

                    dRow["F"] = firmId;
                    dRow["ID"] = line.Substring(0, 10).Trim();//id
                    dRow["BC"] = line.Substring(10, 14).Trim();//skod
                    dRow["NAME"] = line.Substring(24, 35).Trim().Replace('i', 'і').Replace('I', 'І');//name
                    dRow["DESC"] = line.Substring(59, 60).Trim().Replace('i', 'і').Replace('I', 'І');//desc
                    dRow["UNIT"] = line.Substring(119, 15).Trim();//unit
                    dRow["VG"] = line.Substring(134, 1).Trim();//vg
                    if (dRow["VG"].ToString() == "")
                        dRow["VG"] = " ";
                    dRow["TID"] = line.Substring(135, 11).Trim();//tid

                    dRow["TQ"] = MathLib.GetDouble(line.Substring(146, 12).Trim());//tq
                    dRow["PACK"] = MathLib.GetDouble(line.Substring(158, 18).Trim());//pack
                    dRow["WEIGHT"] = MathLib.GetDouble(line.Substring(176, 18).Trim());//weight
                    dRow["PRICE"] = MathLib.GetDouble(line.Substring(194, 12).Trim());//price
                    dRow["PR1"] = MathLib.GetDouble(line.Substring(206, 12).Trim());//pr1
                    dRow["PR2"] = MathLib.GetDouble(line.Substring(218, 12).Trim());//pr2
                    dRow["PR3"] = MathLib.GetDouble(line.Substring(230, 12).Trim());//pr3
                    dRow["Q2"] = MathLib.GetDouble(line.Substring(242, 12).Trim());//q2
                    dRow["Q3"] = MathLib.GetDouble(line.Substring(254, 10).Trim());//q3

                    //dRow["C"] = dRow["ID"];
                    dTable.Rows.Add(dRow);
                    //dRow = dTable.NewRow();

                    sc++;
                }
                Com_WinApi.OutputDebugString("ReadArtSDF_end");

            }
        }
Example #4
0
        private static void ReadAlternative(string path, ref DataTable dTable, int startupIndex)
        {
            byte err_cnt = 0;

            if (File.Exists(path))
            {
                Stream sr = null;
                do
                {
                    try
                    {
                        sr = new FileStream(path, FileMode.Open);
                        break;
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(100);
                        err_cnt++;
                    }

                } while (err_cnt < 10);

                if (sr == null)
                    return;

                BufferedStream buff = new BufferedStream(sr, 131072);
                StreamReader reader = new StreamReader(buff, Encoding.Default);
                StringReader strRd = new StringReader(reader.ReadToEnd());
                sr.Close();
                sr.Dispose();
                string line = string.Empty;
                DataRow dRow = dTable.NewRow();
                int testdsc = 0;
                bool test1 = new Com_SecureRuntime().FullLoader();
                dTable.Rows.Clear();

                string firmId = CoreConst.KEY_DEFAULT_PROFILE_ID;
                if (driver.Config.ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                {
                    string[] fName = Path.GetFileNameWithoutExtension(path).Split(new char[] { '_' });
                    try
                    {
                        firmId = int.Parse(fName[1].Substring(0, 2)).ToString();
                    }
                    catch { }
                }

                dTable.Columns["C"].AutoIncrementSeed = startupIndex + 10 * int.Parse(firmId) + 1;
                if (dTable.Columns["C"].AutoIncrementSeed == 0)
                    dTable.Columns["C"].AutoIncrementSeed = 1;

                Com_WinApi.OutputDebugString("ReadAltSDF_begin");
                while ((line = strRd.ReadLine()) != null)
                {
                    if (line == string.Empty)
                        continue;
                    /*
                    if (!test1 && testdsc >= 10)
                        break;

                    if (test1 && (testdsc + 1) % 100 == 0)
                        test1 = new sgmode.ClassMode().FullLoader();
                    */
                    //dRow["C"] = index++;
                    dRow = dTable.NewRow();
                    dRow["F"] = firmId;
                    dRow["ABC"] = line.Substring(0, 20).Trim();//abc
                    dRow["AID"] = line.Substring(20, 10).Trim();//aid

                    //dRow["C"] = dRow["AID"];
                    dTable.Rows.Add(dRow);
                    //dRow = dTable.NewRow();

                    //testdsc++;
                }
                Com_WinApi.OutputDebugString("ReadAltSDF_end");
                sr.Close();
                sr.Dispose();
            }
        }