Beispiel #1
0
        public void Update(model.master.PlaceOfService p_oPlaceofService, model.user.User p_oUser, model.account.Account p_oAccount)
        {
            SqlCommand    sqlCmd;
            SqlConnection sqlCon = new SqlConnection(sSQLCon);

            sqlCon.Open();
            SqlTransaction sqlTran;

            sqlTran = sqlCon.BeginTransaction();
            try
            {
                sqlCmd                = new SqlCommand("sp_create_placeofservice", sqlCon);
                sqlCmd.CommandType    = CommandType.StoredProcedure;
                sqlCmd.Transaction    = sqlTran;
                sqlCmd.CommandTimeout = 0;
                sqlCmd.Parameters.AddWithValue("@i_id", p_oPlaceofService.Id);
                sqlCmd.Parameters.AddWithValue("@s_address_type", p_oPlaceofService.AddressType);
                sqlCmd.Parameters.AddWithValue("@sz_address1", p_oPlaceofService.Address1);
                sqlCmd.Parameters.AddWithValue("@sz_address2", p_oPlaceofService.Address2);
                sqlCmd.Parameters.AddWithValue("@sz_city", p_oPlaceofService.City);
                sqlCmd.Parameters.AddWithValue("@sz_state", p_oPlaceofService.State);
                sqlCmd.Parameters.AddWithValue("@sz_zipcode", p_oPlaceofService.Zipcode);
                sqlCmd.Parameters.AddWithValue("@sz_company_id", p_oAccount.ID);
                sqlCmd.Parameters.AddWithValue("@sz_code", p_oPlaceofService.Code);
                sqlCmd.Parameters.AddWithValue("@sz_user_id", p_oUser.ID);
                sqlCmd.Parameters.AddWithValue("@sz_created_by", p_oUser.ID);
                sqlCmd.Parameters.AddWithValue("@sz_modified_by", p_oUser.ID);
                sqlCmd.Parameters.AddWithValue("@bt_is_active", p_oPlaceofService.bt_is_active);

                sqlCmd.ExecuteNonQuery();

                sqlTran.Commit();
            }
            catch (Exception ex)
            {
                sqlTran.Rollback();
                throw ex;
            }
            finally
            {
                if (sqlCon.State == ConnectionState.Open)
                {
                    sqlCon.Close();
                }
            }
        }
Beispiel #2
0
        public List <model.master.PlaceOfService> Select(model.account.Account p_oAccount)
        {
            SqlConnection sqlConnection = null;
            List <model.master.PlaceOfService> oList  = new List <model.master.PlaceOfService>();
            List <model.master.PlaceOfService> oList2 = new List <model.master.PlaceOfService>();

            try
            {
                sqlConnection = new SqlConnection(sSQLCon);
                sqlConnection.Open();
                SqlCommand sqlCommand = null;
                sqlCommand             = new SqlCommand("sp_select_placeofservice", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add(new SqlParameter("@sz_company_id", p_oAccount.ID));
                SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
                DataSet        ds = new DataSet();
                da.Fill(ds);
                if (ds != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = ds.Tables[0].Rows[i];
                        model.master.PlaceOfService oElement = new model.master.PlaceOfService();
                        oElement.Id          = Convert.ToInt32(dr["i_id"].ToString());
                        oElement.AddressType = dr["s_address_type"].ToString();
                        oElement.Code        = dr["sz_code"].ToString();
                        oElement.Address1    = dr["sz_address1"].ToString();
                        oElement.Address2    = dr["sz_address2"].ToString();
                        oElement.City        = dr["sz_city"].ToString();
                        oElement.State       = dr["sz_state"].ToString();
                        oElement.Zipcode     = dr["sz_zipcode"].ToString();

                        oList.Add(oElement);
                    }

                    for (var i = 0; i < oList.Count; i++)
                    {
                        model.master.PlaceOfService oElement2 = new model.master.PlaceOfService();

                        oElement2.Id = oList[i].Id;
                        string Address_Type_Code = oList[i].AddressType.ToString() + "-" + oList[i].Code.ToString();
                        oElement2.Address     = oList[i].AddressType.ToString() + "-" + oList[i].Code.ToString() + "," + oList[i].Address1.ToString() + "," + oList[i].Address2.ToString() + "," + oList[i].City.ToString() + "," + oList[i].State.ToString() + "," + oList[i].Zipcode.ToString();
                        oElement2.AddressType = Address_Type_Code;

                        if (oElement2.Address != null)
                        {
                            oElement2.Address.Replace(",,", ",");

                            if (oElement2.Address.StartsWith(",").Equals(true))
                            {
                                //oElement2.Address.Replace(",,", "");
                                //oElement2.Address.Replace(",", "");
                            }

                            if (oElement2.Address.EndsWith(","))
                            {
                                oElement2.Address = oElement2.Address.TrimEnd(',');
                            }
                        }

                        oList2.Add(oElement2);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (sqlConnection.State == ConnectionState.Open)
                {
                    sqlConnection.Close();
                }
            }
            return(oList2);
        }