Esempio n. 1
0
        public serviceAccount GetAccountInfo(int SCCode, string IdentificationSubtype, string AbonCode)
        {
            SqlConnection  sqlcon = new SqlConnection();
            serviceAccount acc    = new serviceAccount();

            try
            {
                sqlcon.ConnectionString = SQLConnectionstring;
                sqlcon.Open();
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt",
                                             DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine +
                                             SQLConnectionstring + Environment.NewLine);
                errorType ert = new errorType();
                ert.errorCode       = errorCode.SYSTEM_ERROR;
                ert.errorDateTime   = DateTime.Now;
                ert.errorData       = new object[1];
                ert.errorData[0]    = SCCode;
                ert.errorObjectType = objectType.SYSTEM;
                CustomSOAPException myexp = new CustomSOAPException("GetAccountInfo", ert, "Verilənlər Bazasına qoşulmaq mümkün olmadı!");
                throw myexp;
            }

            SqlCommand    cmd = new SqlCommand(@"select t.*,Name+' '+Sname+' '+Fname FullName,lcm.Municipal_code from Taxpayer t 
inner join List_classification_Municipal lcm on lcm.MunicipalID=t.MunicipalID where YVOK=@YVOK and t.Fordelete=1 ", sqlcon);
            SqlDataReader reader;

            cmd.Parameters.Add(new SqlParameter("@YVOK", AbonCode));
            reader = cmd.ExecuteReader();

            if (reader.HasRows && reader.Read())//1 sətir olmalıdır. əlavə yoxlama qoymaq lazımdır.
            {
                int colIndex;
                acc.scCode = SCCode;


                acc.identificationSubtype = IdentificationSubtype;

                colIndex = reader.GetOrdinal("Municipal_code");
                string MunicipalCode = reader.IsDBNull(colIndex) ?
                                       string.Empty : reader.GetString(colIndex);
                acc.branchID = Int32.Parse("92" + MunicipalCode);

                colIndex     = reader.GetOrdinal("YVOK");
                acc.abonCode = reader.IsDBNull(colIndex) ?
                               string.Empty : reader.GetString(colIndex);

                if (reader["Individual_Legal"].ToString() == "1")
                {
                    acc.abonType = abonType.P;
                    colIndex     = reader.GetOrdinal("Pincode");
                    acc.pinCode  = reader.IsDBNull(colIndex) ?
                                   string.Empty : reader.GetString(colIndex);

                    colIndex        = reader.GetOrdinal("FullName");
                    acc.description = reader.IsDBNull(colIndex) ?
                                      string.Empty : reader.GetString(colIndex);
                }
                else
                {
                    acc.abonType  = abonType.J;
                    colIndex      = reader.GetOrdinal("VOEN");
                    acc.taxNumber = reader.IsDBNull(colIndex) ?
                                    string.Empty : reader.GetString(colIndex);


                    colIndex        = reader.GetOrdinal("CompanyName");
                    acc.description = reader.IsDBNull(colIndex) ?
                                      string.Empty : reader.GetString(colIndex);
                }



                acc.smartMeter = false;


                if (reader["RegistrationAdress"] == null)
                {
                    acc.address = "-";
                }
                else if (reader["RegistrationAdress"].ToString() == "")
                {
                    acc.address = "-";
                }
                else
                {
                    colIndex    = reader.GetOrdinal("RegistrationAdress");
                    acc.address = reader.IsDBNull(colIndex) ?
                                  string.Empty : reader.GetString(colIndex);
                }


                System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt",
                                             DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO:1:" + acc.abonCode.ToString() + Environment.NewLine);
            }
            else
            {
                errorType ert = new errorType();
                ert.errorCode       = errorCode.NOT_FOUND;
                ert.errorDateTime   = DateTime.Now;
                ert.errorData       = new object[1];
                ert.errorData[0]    = AbonCode;
                ert.errorObjectType = objectType.SERVICE_ACCOUNT;

                CustomSOAPException myexp = new CustomSOAPException("GetAccountInfo", ert);
                throw myexp;
            }

            sqlcon.Close();


            return(acc);
        }
Esempio n. 2
0
        public serviceAccount GetAccountInfoByDocumentNum(int SCCode, string IdentificationSubtype, string DocumentNum)
        {
            SqlConnection sqlcon = new SqlConnection();
            SqlCommand    cmd;

            serviceAccount acc = new serviceAccount();

            try
            {
                sqlcon.ConnectionString = SQLConnectionstring;
                sqlcon.Open();
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt",
                                             DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine);
                errorType ert = new errorType();
                ert.errorCode       = errorCode.SYSTEM_ERROR;
                ert.errorDateTime   = DateTime.Now;
                ert.errorData       = new object[1];
                ert.errorData[0]    = SCCode;
                ert.errorObjectType = objectType.SYSTEM;
                CustomSOAPException myexp = new CustomSOAPException("GetAccountInfoByDocumentNum", ert);
                throw myexp;
            }

            cmd = new SqlCommand("[dbo].[spGetDocumentNum]", sqlcon);
            SqlDataReader reader;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@IdentificationSubtype", IdentificationSubtype));
            cmd.Parameters.Add(new SqlParameter("@DocumentNum", DocumentNum));

            reader = cmd.ExecuteReader();

            if (reader.HasRows && reader.Read())//1 sətir olmalıdır. əlavə yoxlama qoymaq lazımdır.
            {
                int colIndex;

                acc.scCode   = SCCode;
                acc.branchID = SCCode + 99;


                colIndex = reader.GetOrdinal("IdentificationSubtype");
                acc.identificationSubtype = reader.IsDBNull(colIndex) ?
                                            string.Empty : reader.GetString(colIndex);

                if (acc.identificationSubtype == "ACC1")
                {
                    colIndex     = reader.GetOrdinal("AbonCode");
                    acc.abonCode = reader.IsDBNull(colIndex) ?
                                   string.Empty : reader.GetString(colIndex);
                }
                else if (acc.identificationSubtype == "IAMAS")
                {
                    colIndex     = reader.GetOrdinal("PIN");
                    acc.abonCode = reader.IsDBNull(colIndex) ?
                                   string.Empty : reader.GetString(colIndex);
                }

                acc.abonType = abonType.P;

                acc.smartMeter = false;

                colIndex = reader.GetOrdinal("FirstName");
                acc.name = reader.IsDBNull(colIndex) ?
                           string.Empty : reader.GetString(colIndex);

                colIndex    = reader.GetOrdinal("Surname");
                acc.surname = reader.IsDBNull(colIndex) ?
                              string.Empty : reader.GetString(colIndex);

                colIndex       = reader.GetOrdinal("Patronymic");
                acc.secondName = reader.IsDBNull(colIndex) ?
                                 string.Empty : reader.GetString(colIndex);

                colIndex    = reader.GetOrdinal("Address");
                acc.address = reader.IsDBNull(colIndex) ?
                              string.Empty : reader.GetString(colIndex);

                System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt",
                                             DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO:1:" + DateTime.Now + acc.abonCode.ToString() + Environment.NewLine);
            }
            else
            {
                errorType ert = new errorType();
                ert.errorCode       = errorCode.NOT_FOUND;
                ert.errorDateTime   = DateTime.Now;
                ert.errorData       = new object[1];
                ert.errorData[0]    = DocumentNum;
                ert.errorObjectType = objectType.INVOICE;

                CustomSOAPException myexp = new CustomSOAPException("GetAccountInfoByDocumentNum", ert, "Invoice not found for " + SCCode.ToString());
                throw myexp;
            }

            sqlcon.Close();

            return(acc);
        }