public int GetLastid()
        {
            System.Data.SqlClient.SqlDataReader Myreader;
            int Newid;

            sqlCommand.CommandText = "SELECT @@IDENTITY as Newid";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            Newid = Conversions.ToInteger(Myreader["NewID"]);
            Myreader.Close();
            return(Newid);
        }
示例#2
0
        public string ReadCodesForRegion(int regionId)
        {
            var strTemp = new StringBuilder();

            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", regionId);
            sqlCommand.CommandText = "Select code FROM STATIONS WHERE region_id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            while (Myreader.Read())
            {
                strTemp.Append(Myreader["code"].ToString());
            }
            Myreader.Close();
            return(strTemp.ToString());
        }
示例#3
0
        public string GetRegion(int stationId)
        {
            string strTemp = "";

            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", stationId);
            sqlCommand.CommandText = "Select value FROM STATIONS LEFT JOIN REGIONS On REGIONS.ID = STATIONS.region_id WHERE stations.id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            if (Myreader.HasRows)
            {
                strTemp = Myreader["value"].ToString();
            }
            Myreader.Close();
            return(strTemp);
        }
        public bool CanDelete(object id)
        {
            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", id);
            sqlCommand.CommandText = "SELECT id FROM CALLS WHERE priority_id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            if (Myreader.HasRows)
            {
                Myreader.Close();
                return(false);
            }

            Myreader.Close();
            return(true);
        }
示例#5
0
        public void FillComboName()
        {
            string          PdCstr  = "datasource = localhost; database=smartcart; username=root; password=apmsetup;";
            string          Query   = "SELECT name FROM product";
            MySqlConnection PdconDB = new MySqlConnection(PdCstr);
            MySqlCommand    PDcmdDB = new MySqlCommand(Query, PdconDB);
            MySqlDataReader Myreader;

            try
            {
                PdconDB.Open();
                Myreader = PDcmdDB.ExecuteReader();
                while (Myreader.Read())
                {
                    string sName = Myreader.GetString("name");
                    cbBoxPdName.Items.Add(sName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#6
0
        public List <IConvertibleToFormInstance> GetForms(int taxYear)
        {
            var ret = new List <IConvertibleToFormInstance>();


            var ser = new XmlSerializer(typeof(OFX.OFX));

            OFX.OFX ofx;
            using (var tr = new StreamReader(_filePath))
                using (var reader = new Myreader(tr))
                {
                    ofx = (OFX.OFX)ser.Deserialize(reader);
                }

            var transactions = new Dictionary <Form8949Code, List <Form8949Line> >()
            {
                { Form8949Code.A, new List <Form8949Line>() },
                { Form8949Code.B, new List <Form8949Line>() },
                { Form8949Code.C, new List <Form8949Line>() },
                { Form8949Code.D, new List <Form8949Line>() },
                { Form8949Code.E, new List <Form8949Line>() },
                { Form8949Code.F, new List <Form8949Line>() },
            };

            foreach (var item in ofx.Item.TAX1099TRNRS)
            {
                if (item.STATUS.CODE != "0" || item.STATUS.MESSAGE != "SUCCESS" || item.STATUS.SEVERITY != OFX.SeverityEnum.INFO)
                {
                    throw new Exception($"Error import 1099 from {_filePath}: Code: {item.STATUS.CODE} Severity: {item.STATUS.SEVERITY} Message {item.STATUS.MESSAGE}");
                }

                foreach (var f in item.TAX1099RS.Items)
                {
                    var genericForm = (AbstractTaxForm1099)f;
                    if (int.Parse(genericForm.TAXYEAR, CultureInfo.InvariantCulture) != taxYear)
                    {
                        throw new Exception($"Tax year does not match, expected {taxYear}, found {genericForm.TAXYEAR}.");
                    }
                    if (genericForm.CORRECTED == BooleanType.Y)
                    {
                        throw new NotImplementedException("Corrected forms not supported.");
                    }

                    switch (f)
                    {
                    case Tax1099INT_V100 intForm:
                        ret.Add(new Form1099Int()
                        {
                            PayerNameAndAddress = intForm.PAYERADDR.PAYERNAME1,
                            InterestIncome      = ParseMoney(intForm.INTINCOME),
                            TaxExemptInterest   = ParseMoney(intForm.TAXEXEMPTINT),
                        });
                        break;

                    case Tax1099DIV_V100 divForm:
                        ret.Add(new Form1099Div()
                        {
                            PayerNameAndAddress      = divForm.PAYERADDR.PAYERNAME1,
                            TotalOrdinaryDividends   = ParseMoney(divForm.ORDDIV),
                            QualifiedDividends       = ParseMoney(divForm.QUALIFIEDDIV),
                            NondividendDistributions = ParseMoney(divForm.NONTAXDIST),
                            FederalIncomeTaxWithheld = ParseMoney(divForm.FEDTAXWH),
                            Section199ADividends     = ParseMoney(divForm.SEC199A),
                            ForeignTaxPaid           = ParseMoney(divForm.FORTAXPD),
                            ExemptInterestDividends  = ParseMoney(divForm.EXEMPTINTDIV),
                        });
                        break;

                    case Tax1099B_V100 stockForm:
                        foreach (var t in stockForm.EXTDBINFO_V100.PROCDET_V100)
                        {
                            DateTime?acquired = t.Item switch
                            {
                                string s => ParseDate(s),
                                BooleanType.Y => null,
                                _ => throw new Exception($"Unsupported value for acquire time: {t.Item}"),
                            };
                            var code = Enum.Parse <Form8949Code>(t.FORM8949CODE);
                            transactions[code].Add(new Form8949Line(t.SALEDESCRIPTION, acquired, ParseDate(t.DTSALE), ParseMoney(t.COSTBASIS), ParseMoney(t.SALESPR), ParseMoney(t.TOTALADJ)));
                        }
                        break;

                    default:
                        throw new Exception($"Unsupported form type: {f.GetType().Name}");
                    }
                }
            }

            foreach (var kvp in transactions)
            {
                if (kvp.Value.Count != 0)
                {
                    ret.Add(new Form8949(kvp.Key, kvp.Value));
                }
            }

            return(ret);
        }